问题描述
使用Visual Studio 2013年,我已经添加了最新版本的ODP.NET的管理使用的NuGet项目:
安装封装odp.net.managed
的
现在,当我试图运行下面的代码:
数据库DB = DatabaseFactory.CreateDatabase();
它抛出以下异常:
类型'System.ArgumentException'的异常出现在system.data.dll
,但在用户代码中
没有处理其他信息:无法找到所请求的.Net
Framework数据提供。它可能没有安装。
在其他用户的类似的问题阅读,我增加了管理的驱动器部分为C:\Windows\\ \\Microsoft.Net\Framework64\v4.0.30319\Config\machine.config:
<&System.Data这GT ;
< DbProviderFactories><微软SQL Server精简NET Framework数据提供程序添加名称=Microsoft SQL Server压缩数据提供程序4.0不变=System.Data.SqlServerCe.4.0描述= TYPE = System.Data.SqlServerCe.SqlCeProviderFactory,System.Data.SqlServerCe,版本= 4.0.0.0,文化=中性公钥= 89845dcd8080cc91/>
<添加名称=ODP.NET,管理驱动程序不变=Oracle.ManagedDataAccess.Client描述=甲骨文数据提供.NET,管理驱动程序TYPE =Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess,版本= 4.121.1.0,文化=中性公钥= 89b483f429c47342/>
< / DbProviderFactories>
< /system.data>
但是,这并没有影响。
我在我的web.config指明为连接字符串,但我不知道这是否是连看在连接字符串格式,因为它是失败的我打开连接之前:
<&是connectionStrings GT;
<添加名称=OneCDPBuild
的providerName =Oracle.ManagedDataAccess.Client
的connectionString =数据源=数据库;用户ID = IDhere; PWD = passwordhere; />
< /&是connectionStrings GT;
我添加以下到我的web配置:
<&System.Data这GT;
< DbProviderFactories>
<清除不变=Oracle.ManagedDataAccess.Client/>
<添加名称=ODP.NET,管理驱动程序
不变=Oracle.ManagedDataAccess.Client
说明=的Oracle数据提供.NET,管理驱动程序
型=Oracle.ManagedDataAccess.Client.OracleClientFactory,Oracle.ManagedDataAccess,版本= 4.121.1.0,文化=中性公钥= 89b483f429c47342/>
< / DbProviderFactories>
< /system.data>
我会做一个直接的测试,避免启动工厂方法:
VAR康恩=新Oracle.ManagedDataAccess.Client.OracleConnection(连接字符串);
conn.Open();
从bin目录里面没有的问题,这里要么是涉及到Oracle.ManagedDataAccess.dll,或造成连接字符串连接问题(假设你已经可以连接到通过其他手段Oracle实例)。
至于工厂,它看起来像你使用一些过期的企业库代码。在此框架的更高版本,我相信你会用:
VAR厂= DbProviderFactories.GetFactory(ODP.NET,管理驱动器);
VAR康恩= factory.CreateConnection();
我想,如果你把它在一个时间,你会得到更好的反馈的一个步骤。
Using Visual Studio 2013, I've added the latest version of ODP.NET Managed to a project using Nuget:
Install-Package odp.net.managed
http://www.nuget.org/packages/odp.net.managed/121.1.2
Now, when I try to run the following code:
Database db = DatabaseFactory.CreateDatabase();
It throws the following exception:
An exception of type 'System.ArgumentException' occurred
in System.Data.dll but was not handled in user code
Additional information: Unable to find the requested .Net
Framework Data Provider. It may not be installed.
After reading of other users's similar issues, I added the Managed driver section to C:\Windows\Microsoft.Net\Framework64\v4.0.30319\Config\machine.config:
<system.data>
<DbProviderFactories><add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"/>
<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.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
But that had no affect.
I have the connection string specified as such in my web.config, but I'm not sure if it is even looking at the connection string format as it is failing before I open the connection:
<connectionStrings>
<add name="OneCDPBuild"
providerName="Oracle.ManagedDataAccess.Client"
connectionString="Data Source=database;user id=IDhere;pwd=passwordhere;" />
</connectionStrings>
I added the following to my web config:
<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.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
I would start by doing a direct test and avoiding the factory methods:
var conn = new Oracle.ManagedDataAccess.Client.OracleConnection("your connection string");
conn.Open();
Any issues here will either be related to the Oracle.ManagedDataAccess.dll missing from the bin directory, or connectivity issues caused by the connection string (assuming you can already connect to the oracle instance via other means).
As for the factory, it looks like you're using some out of date enterprise library code. In later versions of the framework I believe you would use:
var factory = DbProviderFactories.GetFactory("ODP.NET, Managed Driver");
var conn = factory.CreateConnection();
I think if you take it one step at a time you'll get better feedback.
这篇关于ODP.NET管理 - 无法找到请求的.NET Framework数据提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!