I'm trying to get the Firebird Embedded working in a simple .NET Core (2.1) console application scenario.
My project file looks like this:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FirebirdSql.Data.FirebirdClient" Version="6.4.0" />
</ItemGroup>
</Project>
and Program.cs
like this:
using System;
using System.IO;
using FirebirdSql.Data.FirebirdClient;
namespace Playground
{
class Program
{
static void Main(string[] args)
{
var workingDir = Directory.GetCurrentDirectory();
var dbPath = Path.Combine(workingDir, "Database.fdb");
var connString =
new FbConnectionStringBuilder
{
ClientLibrary = "libfbclient.dylib",
ServerType = FbServerType.Embedded,
UserID = "sysdba",
Database = dbPath
}
.ToString();
Console.WriteLine(connString);
FbConnection.CreateDatabase(connString, false);
var sql =
@"
CREATE TABLE my_table (
id int NOT NULL PRIMARY KEY,
name varchar(20) NOT NULL
);
";
using (var conn = new FbConnection(connString))
using (var cmd = new FbCommand(sql, conn))
{
conn.Open();
cmd.ExecuteNonQuery();
}
}
}
}
After building the project (simply by dotnet build
) I copy following files from the binary package for Mac (Firebird-3.0.4-33054-lipo-x86_64.pkg
) to the output directory (./bin/Debug/netcoreapp2.1
):
libfbclient.dylib
libib_util.dylib
libicudata.dylib
libicui18n.dylib
libicuuc.dylib
plugins (directory)
libEngine12.dylib
Upon running the app (dotnet MyApp.dll
) I get an exception:
Unhandled Exception: FirebirdSql.Data.FirebirdClient.FbException: Unable to complete network request to host "localhost".
Failed to establish a connection. ---> FirebirdSql.Data.Common.IscException: Unable to complete network request to host "localhost".
Failed to establish a connection.
at FirebirdSql.Data.Client.Native.FesDatabase.ProcessStatusVector(IntPtr[] statusVector) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Native\FesDatabase.cs:line 332
at FirebirdSql.Data.Client.Native.FesDatabase.CreateDatabase(DatabaseParameterBuffer dpb, String dataSource, Int32 port, String database, Byte[] cryptKey) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\Client\Native\FesDatabase.cs:line 171
at FirebirdSql.Data.FirebirdClient.FbConnectionInternal.CreateDatabase(DatabaseParameterBuffer dpb) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbConnectionInternal.cs:line 125
at FirebirdSql.Data.FirebirdClient.FbConnection.CreateDatabaseImpl(String connectionString, Int32 pageSize, Boolean forcedWrites, Boolean overwrite) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbConnection.cs:line 101
--- End of inner exception stack trace ---
at FirebirdSql.Data.FirebirdClient.FbConnection.CreateDatabaseImpl(String connectionString, Int32 pageSize, Boolean forcedWrites, Boolean overwrite) in C:\Users\Jiri\Documents\devel\NETProvider\working\Provider\src\FirebirdSql.Data.FirebirdClient\FirebirdClient\FbConnection.cs:line 106
at Playground.Program.Main(String[] args) in /Users/anil/Temp/Playground/Program.cs:line 24
I've used Firebird successfully in many scenarios (network server, embedded) and with different technologies (Delphi, .NET, .NET Core) for last 15 years, albeit only on Windows.
Is anyone able to assist with this issue or point me to the relevant place where I could RTFM and solve it myself?