当我的WPF程序尝试连接到oracle 11g时,出现“OracleInternal.Common.ProviderConfig”错误

9lowa7mx  于 2023-08-07  发布在  Oracle
关注(0)|答案(1)|浏览(368)

我有一个WPF应用程序,由ClickOnce部署,这个应用程序是一个4.8.Net框架的应用程序,它使用的是Oracle.ManagedDataAccess 21.10.0 Nugget包。在几台电脑上都能完美工作,但在一台电脑上就不行了。该计算机也有Oracle 11g客户端和ODAC 12
当应用程序试图打开一个连接,这个错误显示

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

字符串
在我的app.config里有

<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>


线向下...

<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>


我读到这个问题可能是在这个app.config的引用和machine.config中包含的内容,但我真的不知道在那里搜索什么,有什么想法吗?去哪里找?
提前致谢

mwngjboj

mwngjboj1#

我在将控制台应用程序升级到4.8.NETFramework时碰巧遇到了类似的问题。
Oracle.ManagedDataAccess仍在版本12上,该版本有漏洞警告。更新到最新版本后,我的app.config发生了很大的变化。
通过比较生产版的app.config和开发版的app.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>

字符串
新配置:

<?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>


希望这对你有帮助。
谨致问候,
MPO

相关问题