1

啊啊啊。Oracle 和 DotNet 框架代码。

我正在尝试工厂创建一个“ODP.NET,托管驱动程序”

我正进入(状态

找不到请求的 .Net Framework 数据提供程序。它可能没有安装。

我已经走到了下面的极端,以确保它“在那里”。

“原始”与使用工厂调试提示来自这里:ODP.NET Managed - Unable to find requested .Net Framework Data Provider

Program.cs 和“主要”

    private static void MyIssue()
    {
            string oracleConnectionString = GetConnectionStringByName("MyConnectionString");
            using (var conn = new Oracle.ManagedDataAccess.Client.OracleConnection(oracleConnectionString))
            {
                /* lets "prove" the connection string works in a raw fashion */
                conn.Open();
                conn.Close();

                /* THIS (above 2 lines) WORKS */

                System.Reflection.Assembly rawConnectionAssembly = conn.GetType().Assembly;
                ShowAssemblyInfo(rawConnectionAssembly, 1, "rawConnectionAssembly");
            }

            ShowAssemblyInfo(AppDomain.CurrentDomain.GetAssemblies().ToList(), 1, "AppDomain.CurrentDomain.GetAssemblies");




            /* this is debugging for the DbProviderFactories */
            System.Data.DataTable dbfacs = System.Data.Common.DbProviderFactories.GetFactoryClasses();
            System.Data.DataSet ds1 = new DataSet();
            ds1.Tables.Add(dbfacs);
            string xml = ds1.GetXml();

            try
            {
                string magicFactoryName = "ODP.NET, Managed Driver";
                if (!xml.Contains(magicFactoryName))
                {
                    throw new ArithmeticException(string.Format("Missing Factory Name in GetFactoryClasses. {0}", magicFactoryName));
                }

                /* really weird, I see the item in the xml (line above), but it won't created this Factory by that name */ /* THIS FAILS */
                var factory = System.Data.Common.DbProviderFactories.GetFactory(magicFactoryName);
                if (null != factory)
                {
                    var conn2 = factory.CreateConnection();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Intentional SWALLOW : " + GenerateFullFlatMessage(ex));
            }
    }


    private static void ShowAssemblyInfo(ICollection<Assembly> asblies, int nestLevel, string prefixMsg)
    {
        if (null != asblies)
        {
            int counter = 0;
            foreach (Assembly currentAssembly in asblies)
            {
                ShowAssemblyInfo(currentAssembly, nestLevel, "." + Convert.ToString(++counter) + " " + prefixMsg);
            }
        }
    }

    private static void ShowAssemblyInfo(Assembly asbly, int nestLevel, string prefixMsg)
    {
        string prefix = new String(' ', nestLevel);

        if (null != asbly)
        {
            Console.WriteLine("{0}{1} {2} :: {3}", prefix , nestLevel, prefixMsg, asbly.FullName);

            foreach (System.Reflection.AssemblyName assemblyName in asbly.GetReferencedAssemblies())
            {
                System.Reflection.Assembly currentLoopAssembly = System.Reflection.Assembly.Load(assemblyName);
                foreach (System.Reflection.AssemblyName subAssembly in currentLoopAssembly.GetReferencedAssemblies())
                {
                    Console.WriteLine("subAssembly.FullName : {0}", subAssembly.FullName);
                }

                // overflow?
                //ShowAssemblyInfo(currentLoopAssembly, nestLevel++);
            }
        }
    }

    private static string GenerateFullFlatMessage(Exception ex)
    {
        return GenerateFullFlatMessage(ex, false);
    }

    private static string GenerateFullFlatMessage(Exception ex, bool showStackTrace)
    {
        string returnValue;

        StringBuilder sb = new StringBuilder();
        Exception nestedEx = ex;

        while (nestedEx != null)
        {
            if (!string.IsNullOrEmpty(nestedEx.Message))
            {
                sb.Append(nestedEx.Message + System.Environment.NewLine);
            }

            if (showStackTrace && !string.IsNullOrEmpty(nestedEx.StackTrace))
            {
                sb.Append(nestedEx.StackTrace + System.Environment.NewLine);
            }

            if (ex is AggregateException)
            {
                AggregateException ae = ex as AggregateException;

                foreach (Exception flatEx in ae.Flatten().InnerExceptions)
                {
                    if (!string.IsNullOrEmpty(flatEx.Message))
                    {
                        sb.Append(flatEx.Message + System.Environment.NewLine);
                    }

                    if (showStackTrace && !string.IsNullOrEmpty(flatEx.StackTrace))
                    {
                        sb.Append(flatEx.StackTrace + System.Environment.NewLine);
                    }
                }
            }

            nestedEx = nestedEx.InnerException;
        }

        returnValue = sb.ToString();

        return returnValue;
    }

请注意,我没有收到“ArithmeticException”(人造)异常......所以我知道它不是 f@t-finger 语法错误错误。

在此处输入图像描述

应用程序配置

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<configuration>
  <configSections>
  </configSections>

  <appSettings>

  </appSettings>

  <connectionStrings>

    <add name="MyConnectionString"
        connectionString="Data Source=localhost:1521/XE;Persist Security Info=True;User ID=MyOracleSchemaOne;Password=mypassword;"
        providerName="Oracle.ManagedDataAccess.Client"/>


  </connectionStrings>
  <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.19.1, 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.122.19.1" />
      </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>

包.config

错误

找不到请求的 .Net Framework 数据提供程序。它可能没有安装。

但是,它位于 DataTable/DataSet/Xml 中

xml =(注意,最后一个条目,并且有一个密切相关的条目)

<NewDataSet>
  <DbProviderFactories>
    <Name>Odbc Data Provider</Name>
    <Description>.Net Framework Data Provider for Odbc</Description>
    <InvariantName>System.Data.Odbc</InvariantName>
    <AssemblyQualifiedName>System.Data.Odbc.OdbcFactory, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyQualifiedName>
  </DbProviderFactories>
  <DbProviderFactories>
    <Name>OleDb Data Provider</Name>
    <Description>.Net Framework Data Provider for OleDb</Description>
    <InvariantName>System.Data.OleDb</InvariantName>
    <AssemblyQualifiedName>System.Data.OleDb.OleDbFactory, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyQualifiedName>
  </DbProviderFactories>
  <DbProviderFactories>
    <Name>OracleClient Data Provider</Name>
    <Description>.Net Framework Data Provider for Oracle</Description>
    <InvariantName>System.Data.OracleClient</InvariantName>
    <AssemblyQualifiedName>System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyQualifiedName>
  </DbProviderFactories>
  <DbProviderFactories>
    <Name>SqlClient Data Provider</Name>
    <Description>.Net Framework Data Provider for SqlServer</Description>
    <InvariantName>System.Data.SqlClient</InvariantName>
    <AssemblyQualifiedName>System.Data.SqlClient.SqlClientFactory, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyQualifiedName>
  </DbProviderFactories>
  <DbProviderFactories>
    <Name>MySQL Data Provider</Name>
    <Description>.Net Framework Data Provider for MySQL</Description>
    <InvariantName>MySql.Data.MySqlClient</InvariantName>
    <AssemblyQualifiedName>MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.19.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d</AssemblyQualifiedName>
  </DbProviderFactories>
  <DbProviderFactories>
    <Name>ODP.NET, Managed Driver</Name>
    <Description>Oracle Data Provider for .NET, Managed Driver</Description>
    <InvariantName>Oracle.ManagedDataAccess.Client</InvariantName>
    <AssemblyQualifiedName>Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342</AssemblyQualifiedName>
  </DbProviderFactories>
</NewDataSet>

请注意,我也尝试过:

    <DbProviderFactories>
          <!----          <remove invariant="Oracle.ManagedDataAccess.Client"/>  -->
      </clear>

请注意,我看到的一件奇怪的事情是使用“/clear”....我仍然将其作为 xml

<NewDataSet>
  <DbProviderFactories>
    <Name>Odbc Data Provider</Name>
    <Description>.Net Framework Data Provider for Odbc</Description>
    <InvariantName>System.Data.Odbc</InvariantName>
    <AssemblyQualifiedName>System.Data.Odbc.OdbcFactory, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyQualifiedName>
  </DbProviderFactories>
  <DbProviderFactories>
    <Name>OleDb Data Provider</Name>
    <Description>.Net Framework Data Provider for OleDb</Description>
    <InvariantName>System.Data.OleDb</InvariantName>
    <AssemblyQualifiedName>System.Data.OleDb.OleDbFactory, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyQualifiedName>
  </DbProviderFactories>
  <DbProviderFactories>
    <Name>OracleClient Data Provider</Name>
    <Description>.Net Framework Data Provider for Oracle</Description>
    <InvariantName>System.Data.OracleClient</InvariantName>
    <AssemblyQualifiedName>System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyQualifiedName>
  </DbProviderFactories>
  <DbProviderFactories>
    <Name>SqlClient Data Provider</Name>
    <Description>.Net Framework Data Provider for SqlServer</Description>
    <InvariantName>System.Data.SqlClient</InvariantName>
    <AssemblyQualifiedName>System.Data.SqlClient.SqlClientFactory, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</AssemblyQualifiedName>
  </DbProviderFactories>
  <DbProviderFactories>
    <Name>ODP.NET, Managed Driver</Name>
    <Description>Oracle Data Provider for .NET, Managed Driver</Description>
    <InvariantName>Oracle.ManagedDataAccess.Client</InvariantName>
    <AssemblyQualifiedName>Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342</AssemblyQualifiedName>
  </DbProviderFactories>
</NewDataSet>

更新:

我运行 VS2019“作为管理员”,但同样的错误。

我的 machine.config (C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\machine.config )

(那里没有神谕)

  <system.data>
    <DbProviderFactories>
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=8.0.19.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"/>
    </DbProviderFactories>
  </system.data>

关于钓鱼“conn”的输出。

Raw Parent Assembly : Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342


subAssembly.FullName : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.Runtime.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
subAssembly.FullName : System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.DirectoryServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Runtime.Serialization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

更新 (2)

(上面的新 cs 代码...这里有 2 个感兴趣的条目)::

1 rawConnectionAssembly ::                    Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342

1 .9 AppDomain.CurrentDomain.GetAssemblies :: Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342 

整个输出:

1 rawConnectionAssembly ::                    Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342
1 .9 AppDomain.CurrentDomain.GetAssemblies :: Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342 
 
 1 rawConnectionAssembly :: Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342
subAssembly.FullName : System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Runtime.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3asubAssembly.FullName : System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

 1 .1 AppDomain.CurrentDomain.GetAssemblies :: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089


 1 .2 AppDomain.CurrentDomain.GetAssemblies :: MyCompany.ConsoleOne, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullsubAssembly.FullName : System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Runtime.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3asubAssembly.FullName : System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3asubAssembly.FullName : NServiceBus.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c
subAssembly.FullName : RabbitMQ.Client, Version=6.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84cesubAssembly.FullName : System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
subAssembly.FullName : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : System.DirectoryServices.Protocols, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

subAssembly.FullName : MyCompany.MyProj1.NHibernateEntities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullsubAssembly.FullName : NHibernate, Version=5.1.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4subAssembly.FullName : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : Remotion.Linq, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b
subAssembly.FullName : Remotion.Linq.EagerFetching, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b


subAssembly.FullName : System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : NServiceBus.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c
subAssembly.FullName : NHibernate, Version=5.2.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
subAssembly.FullName : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

 1 .3 AppDomain.CurrentDomain.GetAssemblies :: NServiceBus.Core, Version=7.0.0.0, Culture=neutral, PublicKeyToken=9fc386479f8a226c
subAssembly.FullName : System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : System.ServiceModel.Internals, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
subAssembly.FullName : SMDiagnostics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 1 .4 AppDomain.CurrentDomain.GetAssemblies :: System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 1 .5 AppDomain.CurrentDomain.GetAssemblies :: CrowdStrike.Sensor.ScriptControl, Version=5.32.11406.0, Culture=neutral, PublicKeyToken=null
 1 .6 
 1 .7 AppDomain.CurrentDomain.GetAssemblies :: System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3asubAssembly.FullName : System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 1 .8 AppDomain.CurrentDomain.GetAssemblies :: System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 1 .9 AppDomain.CurrentDomain.GetAssemblies :: Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342
subAssembly.FullName : System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Runtime.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3asubAssembly.FullName : System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

 1 .10 AppDomain.CurrentDomain.GetAssemblies :: System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

 1 .11 AppDomain.CurrentDomain.GetAssemblies :: System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
subAssembly.FullName : System.Data.SqlXml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
 1 .12 AppDomain.CurrentDomain.GetAssemblies :: MyCompany.MyProj1.NHibernateMappings, Version=1.0.0.0, Culture=neutral, PublicKeyToken=nullsubAssembly.FullName : NHibernate, Version=5.1.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4subAssembly.FullName : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : Remotion.Linq, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b
subAssembly.FullName : Remotion.Linq.EagerFetching, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b


subAssembly.FullName : System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

 1 .13 AppDomain.CurrentDomain.GetAssemblies :: NHibernate, Version=5.2.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4

subAssembly.FullName : SMDiagnostics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089subAssembly.FullName : System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
subAssembly.FullName : Remotion.Linq, Version=2.2.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b
subAssembly.FullName : System.Xaml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

(我的问题不是太大,我无法更新所有内容:()

4

1 回答 1

0

使用代码时,将显示您拥有的所有提供程序

   static DataTable GetProviderFactoryClasses()
    {
        // Retrieve the installed providers and factories.
        DataTable table = DbProviderFactories.GetFactoryClasses();

        // Display each row and column value.
        foreach (DataRow row in table.Rows)
        {
            foreach (DataColumn column in table.Columns)
            {
                Console.Write(row[column]);
                Console.Write("\t");
            }
            Console.WriteLine(";");
        }

        return table;
    }

错误正是提供程序名称是“Oracle.ManagedDataAccess.Client”但“ODP.NET,托管驱动程序”;我的错误是 DbContext 的构造 connectionstr 错误,它应该像“ConfigurationManager.ConnectionStrings[”OperateLogOracle”].ConnectionString ? ? "name=OperateLogOracle""

于 2021-02-19T06:16:44.937 回答