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

4

我最近配置了一台64位Windows 8.1机器,并安装了32位的Visual Studio 2013(至少它安装在Program Files (x86)目录下)。

我还安装了Oracle 11.2.0.1 64位客户端和Oracle Data Provider for .NET。

当我执行gacutil /l | findstr Oracle.DataAccess时,我会得到四个条目,其中包括以下内容:

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

然而,在尝试添加程序集时,我无法在任何列表中找到Oracle.DataAccess(但是在程序集->扩展下存在Oracle.Web)。

我是否需要安装32位的Oracle客户端(或仅32位ODP.NET),因为Visual Studio是32位的?如果是这样,那么软件是否能够在64位系统上运行,使用64位应用程序和64位Oracle客户端(带有64位ODP.NET)?


这是一个非常老的ODP.NET版本。如果您正在进行新开发,请考虑升级到12.1.0.2。是的,它与v11数据库兼容,并且可以存在于与旧版Oracle客户端相同的机器上。为了与Visual Studio设计师和服务器资源管理器集成,您还需要安装“Oracle Developer Tools for Visual Studio”,只有更新的版本才能与VS 2013配合使用。 - Christian Shay
1个回答

9

是的,Visual Studio是一个32位应用程序。

根据您的编译目标(x86x64AnyCPU),无论Visual Studio的体系结构如何,运行/调试应用程序所需的Oracle客户端都有所不同。

AnyCPU将在64位Windows上作为64位运行(这很可能���情况)

Oracle.DataAccess没有显示,因为它是一个64位组件库,而您的Visual Studio是32位的。

有几种解决方案:

  1. In Add References use the Browse section and locate Oracle.DataAccess.dll manually. Typically you will find it in folder %ORACLE_HOME%\odp.net\bin\2.x\ or %ORACLE_HOME%\odp.net\bin\4\

  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 HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\ODP.NET resp. HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\ODP.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_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\ODP.Net]
    @="c:\\oracle\\product\\11.2\\Client_x86\\odp.net\\bin\\2.x"
    
    [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\ODP.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.


感谢您提供详细和完整的答案。 - Tim Meyer
这不是我的选择 - 抱怨微软吧。当你从一开始就正确安装Oracle,那么默认情况下应该没问题。 - Wernfried Domscheit

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接