Oracle.DataAccess not available for selection in Visual Studio 2013

試著忘記壹切 提交于 2019-12-17 16:49:37

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/28537783/oracle-dataaccess-not-available-for-selection-in-visual-studio-2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!