Principais detalhes ao utilizar o Firebird com .NET

Este post não é um passo a passo de como utilizar o Firebird, mas sim para esclarecer boa parte das dúvidas que geram os principais problemas ao trabalhar com o Firebird em .NET que eu e outros usuários já enfrentamos.

O Firebird .NET não adiciona as DLLs no GAC (Global Assembly Cache) quando instalado, então, por muitas vezes você pode encontrar alguns problemas ao utilizar o Firebird no .NET, por exemplo:

Não foi possível localizar o Provedor de Dados .Net Framework solicitado. Talvez ele não esteja instalado.

Isso acontece principalmente ao tentar utilizar o Firebird com DbCommand, um exemplo do comando que dispara esta exception:

DbProviderFactory factory =  DbProviderFactories.GetFactory("FirebirdSql.Data.FirebirdClient")

Por isso, vale lembrar aqui alguns detalhes ao utilizar o Firebird no .NET

Definir a propriedade Copy Local = True nas Dlls do Firebird referenciadas no projeto.
Adicionar a DLL ao GAC, para isso, abra o Visual Studio 2008 Command Prompt, localizado no Iniciar => Programas => Visual Studio Tools

Digite gacutil -i FirebirdSql.Data.FirebirdClient (Se você não estiver na mesma pasta em que a DLL se encontra, defina o caminho com a DLL, por  exemplo C:\FirebirdSql.Data.FirebirdClient)

Com a DLL adicionada ao GAC, digite gac -l FirebirdSql.Data.FirebirdClient para listar as informações, que deve aparecer conforme abaixo:

The Global Assembly Cache contains the following assemblies:
  FirebirdSql.Data.FirebirdClient, Version=2.1.0.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c, processorArchitecture=MSIL

Number of items = 1

Prestando atenção a detalhes como a Versão (Version) e PublicKeyToken.

Além disso, no web.config (ou app.config no caso de um aplicação winform), adicionar as linhas abaixo:

<system.data>
<DbProviderFactories>
<remove invariant="CoreLab.Oracle"/>
<add name="FirebirdClient Data Provider" invariant="FirebirdSql.Data.FirebirdClient" description=".Net Framework Data Provider for Firebird" type="FirebirdSql.Data.FirebirdClient.FirebirdClientFactory, FirebirdSql.Data.FirebirdClient, Version=2.1.0.0, Culture=neutral,PublicKeyToken=3750abcc3150b00c" />
</DbProviderFactories>
</system.data>

Ao adicionar as linhas acima, fique atendo a detalhes como Version e PublicKeyToken, eles devem ser iguais aos listados quando executamos o comando gacutil -l

Bom, acho que é isso, dúvidas perguntem nos comentários :D

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

2.710 Comments »

 
  • Lincoln MOT disse:

    [...]The information mentioned in the article are some of the best available [...]……

    [...]below you’ll find the link to some sites that we think you should visit[...]……

  • seo sheffield disse:

    [...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……

    [...] Every once in a while we choose blogs that we read. Listed below are the latest sites that we choose [...]… …

  • [...]the time to read or visit the content or sites we have linked to below the[...]……

    [...]here are some links to sites that we link to because we think they are worth visiting[...]……

  • SEO disse:

    UK’s leading SEO Company …

    Offering a complete range of SEO services to match your budget….

  • [...] that is the end of this article. Here you’ll find some sites that we think you’ll appreciate, just click the links over[...]……

    [...] Every once in a while we choose blogs that we read. Listed below are the latest sites that we choose [...]… …

  • hot sexy disse:

    Its hard to find good help…

    I am forever saying that its hard to procure quality help, but here is …

  • Hello…

    I like this weblog very much, Its a really nice spot to read and incur info. “Inflation is the one form of taxation that can be imposed without legislation.” by Milton Friedman….

  • procera avh disse:

    Others…

    [...]Running and swimming, however it wasn’t until I was sure that I was tired that i stopped. [...]…

  • Hard Day…

    It was a hard day here today, so I just took to messing around online and found…

  • Hi…

    Hello, Neat post. There’s a problem together with your web site in internet explorer, might test this… IE nonetheless is the market chief and a large portion of folks will leave out your great writing due to this problem….

 

Deixe uma resposta

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>