Problems with DbProviderFactories.GetFactory and Firebird

Some problems with DbProviderFactories.GetFactory and Firebird (embedded) i found a solution.
Connecting to Fiirebird(embedded) is no problem. After the switch to factories, the problem started.
While try to run

DbProviderFactories.GetFactory("FirebirdSql.Data.FirebirdClient").

if got the error “Unable to find the requested .Net Framework Data Provider. It may not be installed.”

To solve the problem i have used the next 3 sites:
Unable to find the requested .Net Framework Data Provider. It may not be installed.
MSTest.exe not able to load ADO.NET Data providers?
Understanding ADO.Net Provider Factory in .Net 2.0

Note: The software i am writing is not allowed to have admin right. With this in mind machine.config is no option.

To get all up and running i did then next steps :
1)
What info do i need?
The information we need is not easy to find. One way to get the information is using the Global Assembly Cache.
First we install the firebrid dll in the case, this is done in the console as admin
“C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil” -i “D:\Visual Studio 2010\Projects\Test\DatabaseClasses\FirebirdSql.Data.FirebirdClient.dll”

To get the information we simply remove it a again
“C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil” -u FireBirdSQL.Data.FirebirdClient
we the get all info we need

Assembly: FireBirdSQL.Data.FirebirdClient, Version=2.6.5.0, Culture=neutral,
PublicKeyToken=3750abcc3150b00c, processorArchitecture=MSIL

2)
Add the next lines to the Frontend of the app.config in the DbProviderFactoriessetcion

<!-- rao: Firebird driver; prefer locally placed driver (any version)-->
<remove invariant="FirebirdSql.Data.FirebirdClient"/>
<add name="FirebirdSql.Data.FirebirdClient" invariant="FirebirdSql.Data.FirebirdClient" description="Firebird Data Provider for .NET" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Culture=neutral, PublicKeyToken=3750abcc3150b00c"/>

The app.confgi should look like

<?xml version="1.0"?>
<configuration>
    <configSections>
    </configSections>
  <system.data>
    <DbProviderFactories>
      <!-- rao: Firebird driver; prefer locally placed driver (any version)-->
      <remove invariant="FirebirdSql.Data.FirebirdClient"/>
      <add name="FirebirdSql.Data.FirebirdClient" invariant="FirebirdSql.Data.FirebirdClient" description="Firebird Data Provider for .NET" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Culture=neutral, PublicKeyToken=3750abcc3150b00c"/>
    </DbProviderFactories>
  </system.data>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/></startup></configuration>

This created a other problem. Now i got a other error : “‘DbProviderFactories.GetFactoryClasses()’ threw an exception of type ‘System.Configuration.ConfigurationErrorsException'”
This error was created because i put the DbProviderFactories section on the first places. After i moved it to the end it run as expected.

3)
Make sure the Firebird dll are in the same folder as the exe

HTH

One thought on “Problems with DbProviderFactories.GetFactory and Firebird”

Leave a Reply