在 Visual Studio 2013 中无法选择 Oracle.DataAccess

Oracle.DataAccess not available for selection in Visual Studio 2013(在 Visual Studio 2013 中无法选择 Oracle.DataAccess)
本文介绍了在 Visual Studio 2013 中无法选择 Oracle.DataAccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近使用 Visual Studio 2013(可能是 32 位,至少它自己安装在 Program Files (x86) 上)设置了 Windows 8.1 64 位机器.我还安装了带有 Oracle Data Provider for .NET 的 Oracle 11.2.0.1 64 位客户端.

当我做 gacutil/l |findstr Oracle.DataAccess,我得到四个条目,包括以下内容:

Oracle.DataAccess, Version=2.112.1.0, ..., processorArchitecture=AMD64

但是,在尝试添加程序集时,我在任何列表中都找不到 Oracle.DataAccess(不过,Oracle.Web 存在于程序集-> 扩展下).

因为 Visual Studio 是 32 位的,所以我是否必须安装 32 位的 Oracle 客户端(或只是 32 位的 ODP.NET)?如果是这样,该软件能否在具有 64 位应用程序和 64 位 Oracle 客户端(具有 64 位 ODP.NET)的 64 位系统上运行?

解决方案

是的,Visual Studio 是 32 位应用程序.

这取决于运行/调试应用程序所需的 Oracle 客户端的编译目标(x86x64AnyCPU),无论来自 Visual Studio 的架构.

AnyCPU 将在 64 位 Windows 上以 64 位运行(这很可能是这种情况)

Oracle.DataAccess 未出现,因为它是 64 位程序集,但您的 Visual Studio 是 32 位.

有几种解决方案:

  1. Add References 中,使用Browse 部分并手动定位Oracle.DataAccess.dll.通常,您会在 %ORACLE_HOME%odp.netin2.x%ORACLE_HOME%odp.netin4 文件夹中找到它p>

  2. 打开你的 *.csproj,分别.*.vbproj 文件与文本编辑器并手动添加引用,即在元素 下添加这样的行:

    <SpecificVersion>False</SpecificVersion><私人>虚假</私人></参考>

    注意:Version=...processorArchitecture=... 等属性不是必需的.您的应用程序将根据所选架构和目标 .NET 框架加载正确的 Oracle.DataAccess.dll(前提是它已正确安装 - 也在您的目标机器上)

  3. 在您的机器上安装 x86 和 x64 Oracle 客户端.以下是如何执行此操作的说明:堆栈溢出 - 安装 Oracle x86 和 x64

  4. 使用 Oracle 的 ODP.NET 托管驱动程序.您可以从这里下载:64 位 Oracle 数据访问组件 (ODAC) 下载 这也适用于 32 位应用程序.

  5. 打开您的注册表编辑器并检查 RegKey HKLMSOFTWAREWow6432NodeMicrosoft.NETFrameworkv2.0.50727AssemblyFoldersExODP.NET 是否对应.HKLMSOFTWAREWow6432NodeMicrosoft.NETFrameworkv4.0.30319AssemblyFoldersExODP.NET 存在.两个 RegKey 都只包含 (Default) 值和 Oracle.DataAccess.dll 的位置.

    示例:

    Windows 注册表编辑器 5.00 版[HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoft.NETFrameworkv2.0.50727AssemblyFoldersExODP.Net]@="c:\oracle\product\11.2\Client_x86\odp.net\bin\2.x"[HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoft.NETFrameworkv4.0.30319AssemblyFoldersExODP.Net]@="c:\oracle\product\11.2\Client_x86\odp.net\bin\4"

  6. 在编译选项中检查您的目标框架.安装 ODP.NET 4.x 版后,必须选择目标 .NET Framework 4 或更高版本,才能在参考列表中看到 ODP.NET 条目.

I've recently set up a Windows 8.1 64 Bit Machine with Visual Studio 2013 (probably 32 bit, at least it installed itself at Program Files (x86)). I've also installed the Oracle 11.2.0.1 64 Bit Client with Oracle Data Provider for .NET.

When I do gacutil /l | findstr Oracle.DataAccess, I get four entries, including the following:

Oracle.DataAccess, Version=2.112.1.0, ..., processorArchitecture=AMD64

However, I cannot find Oracle.DataAccess in any of the lists when trying to add an assembly (Oracle.Web is present under Assemblies->Extensions, though).

Do I have to install the 32 bit Oracle Client (or simply 32 bit ODP.NET) as Visual Studio is 32 bit? If so, will the software be able to run on a 64 bit system with a 64 bit application and 64 bit Oracle Client (with 64 bit ODP.NET)?

解决方案

Yes, Visual Studio is an 32bit application.

It depends on your compilation target (x86 or x64 or AnyCPU) which Oracle Client you need for running/debugging your application, regardless of the architecture from Visual Studio.

AnyCPU will run as 64 bit on a 64 bit Windows (which is most likely the case)

Oracle.DataAccess does not appear because it is an 64bit assembly but your Visual Studio is 32bit.

There are several solutions:

  1. In Add References use the Browse section and locate Oracle.DataAccess.dll manually. Typically you will find it in folder %ORACLE_HOME%odp.netin2.x or %ORACLE_HOME%odp.netin4

  2. Open your *.csproj, resp. *.vbproj file with a text editor and add reference manually, i.e. add lines like this under element <ItemGroup>:

    <Reference Include="Oracle.DataAccess">
      <SpecificVersion>False</SpecificVersion>
      <Private>False</Private>
    </Reference>
    

    Note: attributes like Version=... or processorArchitecture=... are not required. Your application will load the correct Oracle.DataAccess.dll depending on selected architecture and target .NET framework (provided that it is installed properly - also on your target machine)

  3. Install both x86 and x64 Oracle Client on your machine. Here is an instruction how to do this: Stack Overflow - Install Oracle x86 and x64

  4. Use the ODP.NET Managed Driver from Oracle. You can download it from here: 64-bit Oracle Data Access Components (ODAC) Downloads This works also with 32bit applications.

  5. Open your Registry editor and check if RegKey HKLMSOFTWAREWow6432NodeMicrosoft.NETFrameworkv2.0.50727AssemblyFoldersExODP.NET resp. HKLMSOFTWAREWow6432NodeMicrosoft.NETFrameworkv4.0.30319AssemblyFoldersExODP.NET exist. Both RegKeys contain only the (Default) value with location of your Oracle.DataAccess.dll.

    Example:

    Windows Registry Editor Version 5.00
    
    [HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoft.NETFrameworkv2.0.50727AssemblyFoldersExODP.Net]
    @="c:\oracle\product\11.2\Client_x86\odp.net\bin\2.x"
    
    [HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoft.NETFrameworkv4.0.30319AssemblyFoldersExODP.Net]
    @="c:\oracle\product\11.2\Client_x86\odp.net\bin\4"
    

  6. Check your target Framework in compile options. When you have ODP.NET version 4.x installed you must select target .NET Framework 4 or higher in order to see the ODP.NET entry in reference list.

这篇关于在 Visual Studio 2013 中无法选择 Oracle.DataAccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)