我正在尝试在具有 firebird .net 提供程序(FirebirdSql.Data.FirebirdClient)的 Linux 上使用 Firebird 嵌入式 2.5(64 位)。
我的测试程序集的 FB 嵌入式设置正在使用 Windows Firebird Embedded 版本在 WinX86_64 上运行。在 Linux 上,我使用对应的 FB 嵌入式 Linux 版本将文件放置在程序集目录中:
- libfbembed.so*
- 火鸟.msg
- 安全2.fdb
- 利比库*
- 库*
将“RootDirectory”设置为 firebird.conf 中的程序集目录。将 shell 环境变量 LD_LIBRARY_PATH 和 FIREBIRD 设置为程序集目录。
FbConnectionStringBuilder conn = new FbConnectionStringBuilder();
conn.Database = @"/home/dev/firebirdTest/1stDB.FDB";
conn.ServerType = FbServerType.Embedded;
conn.UserID = "SYSDBA";
conn.Password = "masterkey";
conn.Charset = "UTF8";
conn.DataSource = "localhost";
conn.ClientLibrary = "libfbembed.so";
string connStr = conn.ConnectionString;
var dbcon = new FbConnection(connStr);
FbConnection.CreateDatabase(connStr, pageSize: 8192, forcedWrites: true, overwrite: false);
dbcon = new FbConnection(connStr);
dbcon.Open();
我之前做了什么:
- 通过 mono dllmap 重定向 Firebird Clientlibrary 不起作用。通过在 C# 代码中显式设置 ClientLib 解决。
- 在 Linux 上使用 isql 手动创建数据库是可行的。
- 在 Linux 上通过代码创建数据库是可行的。
- Firebird .NET 提供程序在调试模式下创建 FB_{sanitizedName}.dll 和 DynamicAssembly.dll
- .NET 提供者真的很沉默。通过在 linux 上使用“strace mono {testAssembly.exe}”启动程序集来完成调试。
- 如果页面大小不是 8192,则 FbConnection.CreateDatabase 在“打开 O_CREAT”(调用 FbCreateDatabase)期间因 I/O 错误而崩溃。将显式页面大小设置为 8192 可以解决此问题。
现在,我遇到了以下错误(并在这里停留了好几天......):
打开一个现有的数据库文件(就像这里的代码),崩溃:
FirebirdSql.Data.FirebirdClient.FbException:无效的数据库句柄(无活动连接)---> 无效的数据库句柄(无活动连接)
怎么了?