问题描述
我最近使用 Visual Studio 2013(可能是 32 位,至少它自己安装在 Program Files (x86) 上)设置了 Windows 8.1 64 位机器.我还安装了带有 Oracle Data Provider for .NET 的 Oracle 11.2.0.1 64 位客户端.
当我做 gacutil/l |findstr Oracle.DataAccess,我得到四个条目,包括以下内容:
Oracle.DataAccess, Version=2.112.1.0, ..., processorArchitecture=AMD64
但是,在尝试添加程序集时,我在任何列表中都找不到 Oracle.DataAccess(不过,Oracle.Web 存在于程序集-> 扩展下).
因为 Visual Studio 是 32 位的,所以我是否必须安装 32 位的 Oracle 客户端(或只是 32 位的 ODP.NET)?如果是这样,该软件能否在具有 64 位应用程序和 64 位 Oracle 客户端(具有 64 位 ODP.NET)的 64 位系统上运行?
是的,Visual Studio 是 32 位应用程序.
这取决于运行/调试应用程序所需的 Oracle 客户端的编译目标(x86
或 x64
或 AnyCPU
),无论来自 Visual Studio 的架构.
AnyCPU
将在 64 位 Windows 上以 64 位运行(这很可能是这种情况)
Oracle.DataAccess
未出现,因为它是 64 位程序集,但您的 Visual Studio 是 32 位.
有几种解决方案:
在
Add References
中,使用Browse
部分并手动定位Oracle.DataAccess.dll
.通常,您会在%ORACLE_HOME%odp.netin2.x
或%ORACLE_HOME%odp.netin4
文件夹中找到它p>打开你的
*.csproj
,分别.*.vbproj
文件与文本编辑器并手动添加引用,即在元素
下添加这样的行:<SpecificVersion>False</SpecificVersion><私人>虚假</私人></参考> 注意:
Version=...
或processorArchitecture=...
等属性不是必需的.您的应用程序将根据所选架构和目标 .NET 框架加载正确的Oracle.DataAccess.dll
(前提是它已正确安装 - 也在您的目标机器上)在您的机器上安装 x86 和 x64 Oracle 客户端.以下是如何执行此操作的说明:堆栈溢出 - 安装 Oracle x86 和 x64
使用 Oracle 的 ODP.NET 托管驱动程序.您可以从这里下载:64 位 Oracle 数据访问组件 (ODAC) 下载 这也适用于 32 位应用程序.
打开您的注册表编辑器并检查 RegKey
HKLMSOFTWAREWow6432NodeMicrosoft.NETFrameworkv2.0.50727AssemblyFoldersExODP.NET
是否对应.HKLMSOFTWAREWow6432NodeMicrosoft.NETFrameworkv4.0.30319AssemblyFoldersExODP.NET
存在.两个 RegKey 都只包含(Default)
值和Oracle.DataAccess.dll
的位置.示例:
Windows 注册表编辑器 5.00 版[HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoft.NETFrameworkv2.0.50727AssemblyFoldersExODP.Net]@="c:\oracle\product\11.2\Client_x86\odp.net\bin\2.x"[HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoft.NETFrameworkv4.0.30319AssemblyFoldersExODP.Net]@="c:\oracle\product\11.2\Client_x86\odp.net\bin\4"
在编译选项中检查您的目标框架.安装 ODP.NET 4.x 版后,必须选择目标
.NET Framework 4
或更高版本,才能在参考列表中看到 ODP.NET 条目.
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)?
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.netin2.x
or%ORACLE_HOME%odp.netin4
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
HKLMSOFTWAREWow6432NodeMicrosoft.NETFrameworkv2.0.50727AssemblyFoldersExODP.NET
resp.HKLMSOFTWAREWow6432NodeMicrosoft.NETFrameworkv4.0.30319AssemblyFoldersExODP.NET
exist. Both RegKeys contain only the(Default)
value with location of yourOracle.DataAccess.dll
.Example:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoft.NETFrameworkv2.0.50727AssemblyFoldersExODP.Net] @="c:\oracle\product\11.2\Client_x86\odp.net\bin\2.x" [HKEY_LOCAL_MACHINESOFTWAREWow6432NodeMicrosoft.NETFrameworkv4.0.30319AssemblyFoldersExODP.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.
这篇关于在 Visual Studio 2013 中无法选择 Oracle.DataAccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!