I spent a few hours tonight trying to work out how to get my XAF application using embedded Firebird as a backend. I was unable to find documentation that covered something like this start-to-finish, so I thought I’d jot down my experience in case it helps some other folk using XAF or XPO. In my case, this was on a 64-bit OS, which had me jumping through a few extra hoops.
Let’s get started.
The first step is to download three separate files:
- 32-bit Embedded Firebird
- 64-bit Embedded Firebird
- The Firebird .NET Provider
You can download the files here. At the time of writing I downloaded the 2.5.2 .NET Provider and version 2.1.3 of embedded Firebird.
The second step is to add the following project to your solution:
C:\Program Files (x86)\DevExpress 2009.3\Components\Sources\DevExpress.Xpo\DevExpress.Xpo.Providers\DevExpress.Xpo.Providers.csproj
Now, remove the assembly references and .cs files that are specific to non-Firebird DB’s from the above csproj. Also comment out any lines in the Reg.cs to do with any other drivers aside from Firebird. Next, add a reference to this newly added project to your XAF WinForms project.
The third step is to add a reference to the .NET Firebird provider (FirebirdSql.Data.FirebirdClient.dll, downloaded above) to the WinForms project for your XAF solution.
The fourth step is to change the connection string in your App.config to something like this:
<add name="ConnectionString" connectionString="XpoProvider=Firebird;DataSource=localhost;User=SYSDBA;Password=masterkey;Database=MyDB.fdb;ServerType=1;Charset=NONE"/>
The final step is where this can get tricky – making sure you have the right embedded Firebird DLL’s in the right places for the right project configurations. If you are on 64-bit Windows, as I am, and run the Any CPU configuration, you’ll get files that run as a 64-bit process in bin\Debug. So in here, you’ll want to copy the following files from the 64-bit embedded Firebird zip file:
If you change your configuration to 32-bit, you’ll get files that run as a 32-bit process in bin\x86\Debug, and in here you want to copy the same files above, but from the 32-bit embedded Firebird zip file.
Some gotchas I found include ensuring you have all four of the above DLL’s in your application’s folder. Quite a few references I found only indicated copying in the fbembed.dll file. If you don’t have all of these DLL’s, you’ll get an error message indicating fbembed.dll could not be found.
Another gotcha is ensuring you have the right versions of these files in the right folders when you change configurations. It may seem obvious, but when changing between CPU targets or from Release to Debug and vice versa, new output folders are created, which can again lead to an error message indicating that fbembed.dll could not be found.
Wrapping up, if you get an error indicating fbembed.dll could not be found:
- Ensure you have copied all four of the files listed above – those files exactly
- Ensure you have copied them into the correct folder from which your application is running
If you get an error indicating the incorrect image format:
- Double check your process in task manager – is it 32-bit or 64-bit? – and ensure that you copied the embedded Firebird DLL’s from the proper zip file.
Here are some references I found useful. However, none of them really told the whole story, and some seem outdated.