问题
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:
In
Add References
use theBrowse
section and locateOracle.DataAccess.dll
manually. Typically you will find it in folder%ORACLE_HOME%\odp.net\bin\2.x\
or%ORACLE_HOME%\odp.net\bin\4\
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=...
orprocessorArchitecture=...
are not required. Your application will load the correctOracle.DataAccess.dll
depending on selected architecture and target .NET framework (provided that it is installed properly - also on your target machine)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
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.
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 yourOracle.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"
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