DbProviderFactories for .NET Error

theringostarrs picture theringostarrs · Jan 15, 2010 · Viewed 13.2k times · Source

I am having trouble getting the ODP.NEt library to work with the .NET DBProviderFactories. I am getting the following error with this code:

_DBFactory = DbProviderFactories.GetFactory(providerName);

An error occurred creating the configuration section handler for system.data: Column 'InvariantName' is constrained to be unique. Value 'Oracle.DataAccess.Client' is already present.

with this providerName: Oracle.DataAccess.Client

And the following entry in the web.config:

  <system.data>
    <DbProviderFactories>
      <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" description=".Net Framework Data Provider for Oracle" type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=10.2.0.100, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
  </system.data>

Does anyone know what is wrong? I don't think I have it set up twice anywhere.

Answer

martin picture martin · Mar 16, 2010

If you installed ODP.net (eg using the oracle universal installer, as opposed to xcopy), you'll find the same DbProviderFactories/add in machine.config.

So adding it in your web.config is adding it a second time - so, duplicate Oracle.DataAccess.Client!