以管理ODP.NET组件的问题来自非托管切换.NET项目 [英] Problems switching .NET project from unmanaged to managed ODP.NET assemblies

查看:561
本文介绍了以管理ODP.NET组件的问题来自非托管切换.NET项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的切换.NET项目的管理Oracle使部署变得更加容易。但是我得到在我的测试下面的错误赢服务器2013环境:

无法确定型'Oracle.ManagedDataAccess.Client.OracleConnection'连接的提供者的名称。

我已经采取

步骤至今:

  1. 在删除了所有Oracle.DataAccess的DLL和从溶液中引用
  2. 添加(ODP.NET)所管理的的Oracle数据提供.NET在的NuGet包管理器驱动程序
  3. 交换所有进口Oracle.DataAccess 报表交给进口Oracle.ManagedDataAccess

我没有得到任何编译错误,该项目在本地运行正常。然而,当部署到测试环境中,我得到这个错误。测试环境为Windows Server 2012,并拥有一个传统的Oracle 11.2.0客户端工具安装present。

这是我的连接创建code:

 的Public Sub New()
    MyBase.New(
        新的OracleConnection(
            ConfigurationManager.ConnectionStrings(实体)的ConnectionString)
        真正)
结束小组
 

下面3种不同的风格,我试图连接的configs(包括在当地工作,但对测试环境产生了同样的问题)

(格式化的可见性)

 <添加
      名称=实体
      的connectionString =
          数据Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=###.###.###.###)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=______)));
          用户ID = _____;
          密码= _____;
      的providerName =Oracle.ManagedDataAccess.Client/>

  <添加
      名称=实体
      的connectionString =
          数据Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=###.###.###.###)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=______)));
          用户ID = _____;
          密码= _____;
      的providerName =Oracle.DataAccess.Client/>

  <添加
      名称=实体
      的connectionString =
          数据Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=###.###.###.###)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=______)));
          用户ID = _____;
          密码= _____;
   />
 

任何帮助将是很大的AP preciated!

解决方案

手动下载方法

感谢@Christian吉文的指出了的NuGet版本管理ODAC的不被甲骨文撰写

要使用受管实体框架的Oracle数据访问,在Visual Studio 2012(.NET 4.5):

  1. 拉下实体框架5.0.0.0

    安装-包的EntityFramework -Version 5.0.0

  2. 下载最新的 Oracle数据访问组件(ODAC )

  3. 手动参考 Oracle.ManagedDataAccess.dll

  4. 添加此部分配置文件

< System.Data这>     < D​​bProviderFactories>       <清除不变=Oracle.ManagedDataAccess.Client/>       <添加名称=ODP.NET,管理驱动程序            不变=Oracle.ManagedDataAccess.Client            说明=的Oracle数据提供.NET,管理驱动程序            TYPE =Oracle.ManagedDataAccess.Client.OracleClientFactory,Oracle.ManagedDataAccess,版本= 4.121.1.0,文化=中性公钥= 89b483f429c47342/>     < / DbProviderFactories>   < /system.data>

然后继续像往常一样。它出现在这个时候,实体框架6不支持Oracle.ManagedDataAccess然而,所以需要运行5版

另外请注意,如果你正在使用Visual Studio 2010或更早的版本,针对.NET 4的NuGet将拉低EF5,但使用4.x的组件。我没有测试过这在VS2010与.NET 4。

I'm trying to switch my .NET project over to the manage oracle to make deployments easier. However I'm getting the following error in my test Win Server 2013 environment:

Unable to determine the provider name for connection of type 'Oracle.ManagedDataAccess.Client.OracleConnection'.

Steps I've taken so far:

  1. Removed all Oracle.DataAccess dll's and references from the solution
  2. Added the Oracle Data Provider for .NET (ODP.NET) Managed Driver in the NuGet package manager
  3. Switched all Imports Oracle.DataAccess statements over to Imports Oracle.ManagedDataAccess

I'm not getting any build errors, and the project runs fine locally. However when deployed to the testing environment, I get this error. The test environment is Windows Server 2012, and has a legacy Oracle 11.2.0 client tools installation present.

This is my connection creation code:

Public Sub New()
    MyBase.New(
        New OracleConnection(
            ConfigurationManager.ConnectionStrings("Entities").ConnectionString),
        True)
End Sub

Here are 3 different styles of connection configs that I have tried (both work locally, but yield the same problem on the test environment)

(formatted for visibility)

  <add 
      name="Entities"
      connectionString="
          Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=###.###.###.###)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=______)));
          User Id=_____;
          Password=_____;"
      providerName="Oracle.ManagedDataAccess.Client" />

  <add 
      name="Entities"
      connectionString="
          Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=###.###.###.###)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=______)));
          User Id=_____;
          Password=_____;"
      providerName="Oracle.DataAccess.Client" />

  <add 
      name="Entities"
      connectionString="
          Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=###.###.###.###)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=______)));
          User Id=_____;
          Password=_____;"
   />

Any help would be greatly appreciated!

解决方案

Manual Download Method

Thanks to @Christian Shay for pointing out that the NuGet version of Managed ODAC is not authored by Oracle

To use Managed Oracle Data Access with Entity Framework, in Visual Studio 2012 (.NET 4.5):

  1. Pull down Entity Framework 5.0.0.0

    Install-Package EntityFramework -Version 5.0.0

  2. Download the latest Oracle Data Access Components (ODAC)

  3. Manually reference Oracle.ManagedDataAccess.dll

  4. Add this section to the config file

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

And then proceed as usual. It appears at this time that Entity Framework 6 does not support Oracle.ManagedDataAccess yet, so it is necessary to run version 5.

Also keep in mind that if you are using Visual Studio 2010 or earlier, targeting .NET 4, NuGet will pull down EF5, but use the 4.x assemblies. I have not tested this on VS2010 with .NET 4.

这篇关于以管理ODP.NET组件的问题来自非托管切换.NET项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆