问题描述
我最近用Visual Studio 2013设置了Windows 8.1 64位计算机(可能是32位,至少它自己安装在Program Files(x86)上).我还用Oracle Data Provider for .NET安装了Oracle 11.2.0.1 64位客户端.
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.
当我执行gacutil/l时| findstr Oracle.DataAccess,我得到四个条目,包括以下内容:
When I do gacutil /l | findstr Oracle.DataAccess, I get four entries, including the following:
Oracle.DataAccess, Version=2.112.1.0, ..., processorArchitecture=AMD64
但是,尝试添加程序集时,在任何列表中都找不到Oracle.DataAccess(尽管Oracle.Web位于程序集"->扩展名"下).
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).
由于Visual Studio是32位,我是否必须安装32位Oracle Client(或简单地说是32位ODP.NET)?如果是这样,该软件是否能够在具有64位应用程序和64位Oracle Client(具有64位ODP.NET)的64位系统上运行?
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位应用程序.
Yes, Visual Studio is an 32bit application.
这取决于您的编译目标(x86
或x64
或AnyCPU
),无论运行Visual Studio的体系结构是什么,运行或调试应用程序都需要哪个Oracle客户端.
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
将在64位Windows上以64位运行(很可能是这种情况)
AnyCPU
will run as 64 bit on a 64 bit Windows (which is most likely the case)
Oracle.DataAccess
不会出现,因为它是64位程序集,但是您的Visual Studio是32位.
Oracle.DataAccess
does not appear because it is an 64bit assembly but your Visual Studio is 32bit.
有几种解决方案:
-
在
Add References
中,使用Browse
部分并手动找到Oracle.DataAccess.dll
.通常,您会在文件夹%ORACLE_HOME%\odp.net\bin\2.x\
或%ORACLE_HOME%\odp.net\bin\4\
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\
分别打开您的*.csproj
.使用文本编辑器的*.vbproj
文件并手动添加引用,即在元素<ItemGroup>
下添加这样的行:
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>
注意:不需要Version=...
或processorArchitecture=...
之类的属性.您的应用程序将根据所选的体系结构和目标.NET框架(前提是已正确安装-也在目标计算机上)加载正确的Oracle.DataAccess.dll
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)
在计算机上同时安装x86和x64 Oracle Client.以下是如何执行此操作的说明:
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
使用Oracle的ODP.NET托管驱动程序.您可以从此处下载: 64位Oracle数据访问组件(ODAC)下载这也适用于32位应用程序.
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.
打开注册表编辑器,然后检查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
的位置.
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
.
示例:
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条目.
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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!