Firebird .NET provider and embedded server 3

梦想与她 提交于 2019-12-10 13:21:26

问题


I'm trying to use .NET Firebird Provider to connect to the embedded FB 3.0.1 server.

As far as I know, (also written here (page 6)), there is no more fbclient.dll\fbembed.dll but a single client fbclient.dll used for remote and embedded access.

But when I call the FBConnection.Open() I get a System.DllNotFoundException:

Unable to load DLL 'fbembed': 
Impossible to find the specified module (Exception from HRESULT: 0x8007007E).

Any ideas?


回答1:


Looking in the Provider code the default Client Library is fbembed (maybe for compatibility):

internal const string DefaultValueClientLibrary = "fbembed";

Now, passing the new value to the ConnectionString do the trick:

  var connectionString = new FbConnectionStringBuilder
  {
    Database = dbPath,
    ServerType = FbServerType.Embedded,
    UserID = "SYSDBA",
    Password = "masterkey",
    ClientLibrary = "fbclient.dll"
  }.ToString();



回答2:


This took a while to figure out. But I got it to work....

For embedded client:
Run the NuGet command: Install-Package FirebirdSql.Data.FirebirdClient

For embedded server:
Key point: The dll's are NOT added to Visual Studio as a project reference. Instead, their location is defined in the connection string.

Download the full server zip from here. Then extract these three files to your project. Use a structure similar to below (or at least make sure a "plugins" sub-directory is defined or the FB server will throw an error).
my_project\firebird_server\fbclient.dll

my_project\firebird_server\ib_util.dll

my_project\firebird_server\plugins\engine12.dll

Then setup connection string:

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; 


来源:https://stackoverflow.com/questions/41980813/firebird-net-provider-and-embedded-server-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!