【问题标题】:Firebird .NET provider and embedded server 3Firebird .NET 提供程序和嵌入式服务器 3
【发布时间】:2017-02-01 13:17:32
【问题描述】:

我正在尝试使用 .NET Firebird Provider 连接到嵌入式 FB 3.0.1 服务器。

据我所知,(也写成here (page 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).

有什么想法吗?

【问题讨论】:

    标签: c# firebird firebird-3.0 firebird-embedded firebird-.net-provider


    【解决方案1】:

    在提供程序代码中查看默认客户端库是 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,这应该取决于平台(Windows 至少 32/64 位)。看看 FesDatabase 和 ClientFactory,真是头疼。
    • @vitalygolub 您的评论有何贡献?如果 OP 想使用 C# 中嵌入的 Firebird,那么这是唯一的方法。
    【解决方案2】:

    这需要一段时间才能弄清楚。但我得到了它的工作......

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

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

    here 下载完整的服务器压缩包。然后将这三个文件解压到你的项目中。使用类似于下面的结构。

    • 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; 
    

    【讨论】:

    • firebird 3.03 还需要 ciu*.dll,如果找不到会抛出错误
    • firebird 3.0.4 需要的额外文件:icudt52.dll、icudt52l.dat、icuuc52.dll
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-22
    • 1970-01-01
    • 2018-09-03
    • 2012-02-12
    相关资源
    最近更新 更多