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

954 Views Asked by At

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

2

There are 2 best solutions below

0
On BEST ANSWER

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.

0
On

I happened to have run into a similar issue while upgrading a console application to 4.8 .NET Framework.

Oracle.ManagedDataAccess was still on version 12 which had a vulnerability warning. After updating to the latest version my app.config changed considerably.

By comparing the production app.config with the one in development and making appropriate changed i got things running again.

Old config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <section name="oracle.manageddataaccess.client"
      type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
    </configSections>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
    </startup>
    <log4net>
        <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
            <file type="log4net.Util.PatternString" value="application.log"/>
            <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
            <rollingStyle value="Composite"/>
            <datePattern value="yyyyMMdd"/>
            <maxSizeRollBackups value="10"/>
            <maximumFileSize value="10MB"/>
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%date{dd-MM-yyyy HH:mm:ss} %-5level %logger - %message%newline"/>
            </layout>
            <filter type="log4net.Filter.LevelRangeFilter">
                <levelMin value="DEBUG"/>
                <levelMax value="FATAL"/>
            </filter>
        </appender>
        <appender name="TraceAppender" type="log4net.Appender.TraceAppender">
            <layout type="log4net.Layout.PatternLayout">
                <param name="Header" value="[Header]\r\n"/>
                <param name="Footer" value="[Footer]\r\n"/>
                <param name="ConversionPattern" value="%date{dd-MM-yyyy HH:mm:ss} [%t] %-5p %c %m%n"/>
            </layout>
        </appender>
        <root>
            <level value="DEBUG"/>
            <appender-ref ref="RollingFileAppender"/>
            <appender-ref ref="TraceAppender"/>
        </root>
    </log4net>
    <connectionStrings>
    </connectionStrings>
    <appSettings>
    </appSettings>
    <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.121.2.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
        </DbProviderFactories>
    </system.data>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <publisherPolicy apply="no"/>
                <assemblyIdentity name="Oracle.ManagedDataAccess" publicKeyToken="89b483f429c47342" culture="neutral"/>
                <bindingRedirect oldVersion="4.121.0.0 - 4.65535.65535.65535" newVersion="4.121.2.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
    <oracle.manageddataaccess.client>
        <version number="*">
            <dataSources>
                <dataSource alias="SampleDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=ORCL))) "/>
            </dataSources>
        </version>
    </oracle.manageddataaccess.client>
</configuration>

New config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
    </configSections>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
    </startup>
    <log4net>
        <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
            <file type="log4net.Util.PatternString" value="application.log"/>
            <lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
            <rollingStyle value="Composite"/>
            <datePattern value="yyyyMMdd"/>
            <maxSizeRollBackups value="10"/>
            <maximumFileSize value="10MB"/>
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="%date{dd-MM-yyyy HH:mm:ss} %-5level %logger - %message%newline"/>
            </layout>
            <filter type="log4net.Filter.LevelRangeFilter">
                <levelMin value="DEBUG"/>
                <levelMax value="FATAL"/>
            </filter>
        </appender>
        <appender name="TraceAppender" type="log4net.Appender.TraceAppender">
            <layout type="log4net.Layout.PatternLayout">
                <param name="Header" value="[Header]\r\n"/>
                <param name="Footer" value="[Footer]\r\n"/>
                <param name="ConversionPattern" value="%date{dd-MM-yyyy HH:mm:ss} [%t] %-5p %c %m%n"/>
            </layout>
        </appender>
        <root>
            <level value="DEBUG"/>
            <appender-ref ref="RollingFileAppender"/>
            <appender-ref ref="TraceAppender"/>
        </root>
    </log4net>
    <connectionStrings>
    </connectionStrings>
    <appSettings>
    </appSettings>
    <system.web>
    <membership defaultProvider="ClientAuthenticationMembershipProvider">
      <providers>
        <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
      </providers>
    </membership>
    <roleManager defaultProvider="ClientRoleProvider" enabled="true">
      <providers>
        <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
      </providers>
    </roleManager>
  </system.web>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Hope this helps.

Kind regards,

MPO