Search code examples
c#wpforacle.manageddataaccess

I am having 'OracleInternal.Common.ProviderConfig' error when my WPF program try to connect to oracle 11g


I have a WPF application, deployed by ClickOnce, this application is a 4.8 .Net framework's application and it is using Oracle.ManagedDataAccess 21.10.0 Nugget package. Works perfect in several computers, but in one doesn't. That computer has Oracle 11g client and ODAC12 too

Whe the application try to open a connection this error shows up

An exception occurred in the initializer of type 'OracleInternal.Common.ProviderConfig'.

At my app.config I have this

  <oracle.manageddataaccess.client>
    <version number="*">
      <dataSources>
        <dataSource alias="XXX" descriptor="(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = prdbd-scan)(PORT = 1521))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = srv)))" />
      </dataSources>
    </version>
  </oracle.manageddataaccess.client>

Lines down...

  <system.data>
    <DbProviderFactories>
      <remove invariant="Oracle.ManagedDataAccess.Client" />
      <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" />
    </DbProviderFactories>
  </system.data>

I read that the problem maybe in the reference in this app.config and what is included in machine.config, but I really don't know what to search there, any idea? where to look?

thanks in advance


Solution

  • My solution to this issue was:

    1. in app.config remove the referencess to oracle.manageddataaccess like this:

      <section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.122.21.1, Culture=neutral, PublicKeyToken=89b483f429c47342" />
      
    2. include a tnsnames.ora file in the root of the project.

    that's all. I hope this help someone else.