Firebird .NET提供程序和嵌入式服务器3

7
我正在尝试使用.NET Firebird Provider连接到嵌入式FB 3.0.1服务器。
据我所知,(也在这里(第6页)中写道),不再存在fbclient.dll\fbembed.dll,而是一个用于远程和嵌入式访问的单个客户端fbclient.dll。
但是,当我调用FBConnection.Open()时,我会收到System.DllNotFoundException:
Unable to load DLL 'fbembed': 
Impossible to find the specified module (Exception from HRESULT: 0x8007007E).

任何想法?
2个回答

6

在提供程序代码中,fbembed是默认的客户端库(可能是为了兼容性):

internal const string DefaultValueClientLibrary = "fbembed";

现在,将新值传递给ConnectionString就可以解决问题了。
  var connectionString = new FbConnectionStringBuilder
  {
    Database = dbPath,
    ServerType = FbServerType.Embedded,
    UserID = "SYSDBA",
    Password = "masterkey",
    ClientLibrary = "fbclient.dll"
  }.ToString();

不错,但在我看来这并不是主要问题,你可以只需重命名dll文件。问题在于,嵌入式服务器根本没有被管理,它使用本地dll,并且您必须提供本地客户端dll,该dll应该依赖于平台(至少对于Windows的32/64位)。看看FesDatabase和ClientFactory,这真是让人头疼的问题。 - vitalygolub
2
@vitalygolub你的评论有什么贡献吗?如果OP想在C#中使用Firebird Embedded,那就只有这种方法。 - Mark Rotteveel

4

这个问题花了一些时间才解决,但我最后搞定了。...

对于嵌入式客户端:
运行NuGet命令:Install-Package FirebirdSql.Data.FirebirdClient

对于嵌入式服务器:
关键点:dll文件不作为项目引用添加到Visual Studio中,而是在连接字符串中定义它们的位置。

这里下载完整的服务器压缩包。然后将这三个文件提取到您的项目中。使用类似以下结构的结构。

  • my_project\firebird_server\fbclient.dll
  • my_project\firebird_server\ib_util.dll
  • my_project\firebird_server\plugins\engine12.dll //是的,需要将其放在“plugins”子目录中,否则firebird服务器会抛出错误。

然后设置连接字符串:

Database=c:\sample_firebird_database.FDB;
User=my_username;
Password=my_password;
ServerType=1; // 1 = embedded server
Charset=UTF8;
ClientLibrary=c:\my_project\firebird_server\fbclient.dll; 

1
还需要ciu*.dll文件来支持Firebird 3.03,如果找不到会抛出错误。 - bh_earth0
Firebird 3.0.4所需的额外文件:icudt52.dll、icudt52l.dat和icuuc52.dll。 - Carlos Alberto Flores Onofre

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接