Firebird .NET provider and embedded server 3
Asked Answered
A

2

7

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?

Alishiaalisia answered 1/2, 2017 at 13:17 Comment(0)
A
6

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();
Alishiaalisia answered 1/2, 2017 at 13:54 Comment(2)
Nice, but imho it is not the main problem, you can just rename dll file. The problem is, that embedded server is not managed at all, it uses native dll and you have to provide native client dll, which should depend from platform (at least 32/64 bit for windows). Look at FesDatabase and ClientFactory, it is pain in ass.Spraddle
@Spraddle What does your comment contribute? If the OP wants to use Firebird Embedded in C#, then that is the only way.Paltry
V
4

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.

  • my_project\firebird_server\fbclient.dll
  • my_project\firebird_server\ib_util.dll
  • my_project\firebird_server\plugins\engine12.dll //Yes, need to have this in a "plugins" subdirectory otherwise firebird server will throw error.

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; 
Vernettaverneuil answered 12/3, 2017 at 5:23 Comment(2)
also requires ciu*.dll for firebird 3.03, if not found throws errorTello
Extra files required for firebird 3.0.4: icudt52.dll, icudt52l.dat, icuuc52.dllSuperman

© 2022 - 2024 — McMap. All rights reserved.