在 Visual Studio 2013 中无法选择 Oracle.DataAccess
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28537783/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle.DataAccess not available for selection in Visual Studio 2013
提问by Tim Meyer
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.
我最近使用 Visual Studio 2013(可能是 32 位,至少它安装在 Program Files (x86) 上)设置了 Windows 8.1 64 位机器。我还安装了带有 Oracle Data Provider for .NET 的 Oracle 11.2.0.1 64 位客户端。
When I do gacutil /l | findstr Oracle.DataAccess, I get four entries, including the following:
当我做 gacutil /l | findstr Oracle.DataAccess,我得到四个条目,包括以下内容:
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).
但是,在尝试添加程序集时,我无法在任何列表中找到 Oracle.DataAccess(不过,Oracle.Web 存在于程序集-> 扩展程序下)。
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)?
由于 Visual Studio 是 32 位,我是否必须安装 32 位 Oracle 客户端(或只是 32 位 ODP.NET)?如果是这样,该软件能否在具有 64 位应用程序和 64 位 Oracle 客户端(具有 64 位 ODP.NET)的 64 位系统上运行?
回答by Wernfried Domscheit
Yes, Visual Studio is an 32bit application.
是的,Visual Studio 是一个 32 位应用程序。
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.
这取决于你的编译目标(x86
或x64
或AnyCPU
)Oracle客户端,你需要运行/调试应用程序,无论从Visual Studio架构的哪个。
AnyCPU
will run as 64 bit on a 64 bit Windows (which is most likely the case)
AnyCPU
将在 64 位 Windows 上以 64 位运行(很可能是这种情况)
Oracle.DataAccess
does not appear because it is an 64bit assembly but your Visual Studio is 32bit.
Oracle.DataAccess
不会出现,因为它是 64 位程序集,但您的 Visual Studio 是 32 位。
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) DownloadsThis 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.
在
Add References
使用Browse
部分并Oracle.DataAccess.dll
手动定位。通常,您会在文件夹%ORACLE_HOME%\odp.net\bin\2.x\
或%ORACLE_HOME%\odp.net\bin\4\
打开你的
*.csproj
,分别。*.vbproj
使用文本编辑器创建文件并手动添加引用,即在 element 下添加这样的行<ItemGroup>
:<Reference Include="Oracle.DataAccess"> <SpecificVersion>False</SpecificVersion> <Private>False</Private> </Reference>
注意:像
Version=...
或processorArchitecture=...
这样的属性不是必需的。您的应用程序将Oracle.DataAccess.dll
根据所选架构和目标 .NET 框架加载正确的内容(前提是它已正确安装 - 也在您的目标机器上)在您的机器上安装 x86 和 x64 Oracle Client。以下是如何执行此操作的说明:堆栈溢出 - 安装 Oracle x86 和 x64
使用 Oracle 的 ODP.NET 托管驱动程序。您可以从这里下载:64 位 Oracle 数据访问组件 (ODAC) 下载这也适用于 32 位应用程序。
打开您的注册表编辑器并检查 RegKey 是否对应
HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\ODP.NET
。HKLM\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\ODP.NET
存在。两个 RegKey 都只包含(Default)
您的Oracle.DataAccess.dll
.例子:
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"
在编译选项中检查您的目标框架。安装 ODP.NET 4.x 版后,您必须选择目标
.NET Framework 4
或更高版本才能在参考列表中看到 ODP.NET 条目。