无法在 .NET 中加载 Oracle.DataAccess 的文件或程序集

发布于 2024-08-15 09:15:44 字数 330 浏览 4 评论 0原文

当我尝试运行一个简单的程序来访问 oracle 时,我收到此消息

无法加载文件或程序集“Oracle.DataAccess, 版本=2.111.7.20,文化=中性,PublicKeyToken=89b483f429c47342' 或其依赖项之一。系统找不到指定的文件。

我检查了 \windows\Assembly,它就在那里,但它不在 GAC 中 (gacutil -l)。我无法添加到 GAC(gacutil -i [path])。我收到“未知错误”。

有人有同样的经历吗?

When I try to run a simple program to access oracle I am getting this message

Could not load file or assembly 'Oracle.DataAccess,
Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342'
or one of its dependencies. The system cannot find the file specified.

I checked \windows\assembly and it's in there, but it's not in GAC (gacutil -l). I can't add into GAC (gacutil -i [path]. I get 'unknown error'.

Anyone has the same experiencing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(13

向地狱狂奔 2024-08-22 09:15:44

我将根据我刚刚在 64 位操作系统 Windows Server 2008 R2 上经历的情况给您答案。我得到的应用程序库套件是使用 .net 3.5 x86 和较旧的 DLL 库开发的,但我陷入了困境,因为我安装了来自 Oracle 的较新的 x64 客户端。

我发现的是以下内容:
安装 Oracle for Windows Server 2008 的最新 x64 客户端。我相信这将是 2.7.0 客户端。选择安装时,请确保进行自定义并选择 .NET 库。
配置 tnsnames 文件并针对数据源测试 tnsping。

接下来,如果您运行的是 32 位应用程序,请安装相同版本的 32 位客户端。另外,遵循相同的安装例程,并选择相同的主目录。

完成后,您会发现您有一个带有两个客户端目录(Client1 和 Client2)的应用程序/产品。

如果导航到 windows/assemblies 目录,您会发现有一个对 Oracle.DataAccess.dll (x2) 的引用,其中一个用于 x86,一个用于 AMD64。

现在,根据您是否有开发人员或自己在机器上进行开发,您可能在这里没问题,但是,如果他们使用较旧的驱动程序,那么您需要执行最后一步。

导航到 app\name\product\version\client_1\odp.net\publisherpolicy\2.x 目录。这里包括两个策略文件。使用 gacutil /i 将 Policy.2.111.Oracle.DataAccess.dll 安装到 GAC 中。这会将旧的 Oracle ODP 调用重定向到较新的版本。因此,如果有人使用 10g 客户端进行开发,那么它现在也可以使用 11 客户端。

仅供参考——有些人可能会安装最新的 ODP.NET 2.111.7.20。主要的 oracle 客户端本身带有 2.111.7.0 .. 我在 7.20 上没有取得任何成功,但在 7.0 客户端上没有任何问题。

I'm going to give you the answers from what I've just went through on Windows Server 2008 R2 which is a 64 bit operating system. The application suite of libraries I was given were developed using .net 3.5 x86 with the older DLL libraries and I was stuck because I had installed the newer x64 clients from oracle.

What I found was the following:
Install the latest x64 client from Oracle for Windows Server 2008. I believe this would be the 2.7.0 client. When you select the installation, make sure you do custom and select the .NET libraries.
Configure your tnsnames files and test your tnsping against your data source.

Next, if you are running a 32 bit application, install the same version of the client for 32 bit. Also, follow the same installation routine, and select the same home.

When your finished, you will find that you have a single app/product with two client directories (Client1 and Client2).

If you navigate to the windows/assemblies directory you will find that you have a reference to the Oracle.DataAccess.dll (x2) with one for x86 and one for AMD64.

Now, depending on if you have developers or are developing on the machine yourself, you may be ok here, however, if they are using older drivers, then you need to perform one last step.

Navigate to the app\name\product\version\client_1\odp.net\publisher policy\2.x directory. Included in here are two policy files. use gacutil /i to install the Policy.2.111.Oracle.DataAccess.dll into the GAC. This will redirect legacy oracle ODP calls to the newer versions. So, if someone developed with the 10g client, it will now work with the 11 client.

FYI -- Some may be installing the latest ODP.NET with the 2.111.7.20. The main oracle client itself comes with 2.111.7.0 .. I've not had any success with the 7.20 but have no issues with the 7.0 client.

可爱咩 2024-08-22 09:15:44

我是用x64编译的,只要使用x86就可以解决问题

I was compiling in x64, just use x86 and it will solve the problem

墨小墨 2024-08-22 09:15:44

解决方案非常简单,关键在于如何在服务器/工作站上定义与 Visual Studio 项目相关的事物。

首先检查您正在使用的 Oracle 库的版本,在您的示例中为 2.111.7.20。接下来转到位于 Windows 主目录->程序集文件夹中的 Windows GAC。

向下滚动到 Oracle dll,它通常称为 Oracle.DataAccess 或 Oracle.Web。找到正确的版本并记下它是否显示 x86 或 AMD64。

在Visual Studio中确保您的目标平台与GAC中的dll相同,因此如果GAC文件夹中显示x86,请确保目标平台是x64和其他x64。您可以在 Visual Studio 项目属性中的构建/平台目标下进行设置。

还要确保项目中的引用下的引用指向开发计算机上的完全相同的版本。

有了这个,一切都应该正常工作。

我通常做的是首先检查服务器,因为在企业环境中更改本地依赖项的版本通常更容易,然后要求服务器管理员安装不同的 dll。

The solution is quite simple, it is all a matter of how you define things on the server / workstation in relation to your visual studio project.

First check the version of the Oracle library that you are using, in your case 2.111.7.20. Next go to the Windows GAC located in your windows home->assembly folder.

Scroll down to the Oracle dll, it is normally called Oracle.DataAccess or Oracle.Web. Find the right version of it and note down if it says x86 or AMD64.

In visual studio ensure that your target platform is the same as the dll in the GAC, so if it says x86 in the GAC folder ensure that the target platform is x64 and other x64. You can set this in Visual Studio project properties, under build/platform target.

Also ensure that your reference, under references in your project points to this exact same version on your development computer.

With this everything should work fine.

What I normally do is to check the server first as it is often easier in an enterprise environment to change the version of your local dependencies, then to ask a server administrator to do an installation of a different dll.

以可爱出名 2024-08-22 09:15:44

我有同样的问题。

解决方案是将我当前解决方案的平台更改为 x64。

要在 Visual Studio 中执行此操作,请右键单击解决方案 >配置管理器>主动解决方案平台。

I had the same issue.

Solution was to change the platform of my current solution to x64.

To do that in Visual Studio, right click solution > Configuration Manager > Active Solution Platform.

擦肩而过的背影 2024-08-22 09:15:44

正如第一个答案中提到的,32/64 位场景会给开发人员带来构建和运行时陷阱。

解决方案始终是尝试正确:您安装了哪种软件和操作系统

有关 Oracle 驱动程序和解决方案的一小部分场景列表,您可以访问此 帖子

As referred to in the first answer, there are 32/64 bit scenarios which introduce build and runtime pitfalls for developers.

The solution is always to try to get right: What kind of software and OS you have installed.

For a small list of scenarios with the Oracle driver and the solution, you can visit this post.

魂ガ小子 2024-08-22 09:15:44

在您的 .net 项目中,转到参考部分,右键单击 Oracle.DataAccess dll,转到属性。

将设置更改为“特定版本=False”。现在不会有版本冲突了

in your .net project go to reference section, right click on Oracle.DataAccess dll, goto properties.

Change the setting to "Specific Version=False". Now it will be no version conflict

┾廆蒐ゝ 2024-08-22 09:15:44

就我而言,错误表明程序

Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342

集丢失。

当我运行 gacutil.exe /l 'Oracle.DataAccess' 时,结果是:

The Global Assembly Cache contains the following assemblies:
Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86

Number of items = 1

此时我刚刚安装了 oracle 客户端: win32_11gR2_client

然后我安装了 oracle 开发者工具 < code>ODTwithODAC112030_deleloper_tool

现在 gacutil 说:

The Global Assembly Cache contains the following assemblies:
Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86
Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86

Number of items = 2

已修复,一个完全丢失的汇编案例

In my case the error states that the assemly

Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342

is missing.

When I run gacutil.exe /l 'Oracle.DataAccess' the result was:

The Global Assembly Cache contains the following assemblies:
Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86

Number of items = 1

At this moment I have just installed the oracle client: win32_11gR2_client

Then I installed oracle developer tools ODTwithODAC112030_deleloper_tool

Now gacutil is saying:

The Global Assembly Cache contains the following assemblies:
Oracle.DataAccess, Version=2.112.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86
Oracle.DataAccess, Version=2.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86

Number of items = 2

Fixed, one totally missing assembly case

眼波传意 2024-08-22 09:15:44

请尝试以下操作: 在 Visual Studio 中,转到“工具/选项...项目和解决方案...Web 项目...”确保选中“64 位版本的 IIS Express”复选框。

Try the following: In Visual Studio, go to Tools/Options....Projects and Solutions...Web Projects... Make sure that 64 bit version of IIS Express checkbox is checked off.

执笔绘流年 2024-08-22 09:15:44

我切换到 Oracle 的托管 ODP.NET 程序集。我还必须从使用旧程序集的 IIS Web 应用程序中清除所有文件。现在,当我在 IIS Express 与 IIS 中进行调试时,我没有遇到任何关于 32 位版本与 64 位版本的冲突。请参阅以下文章。

轻松驱动 .NET

I switched over to the managed ODP.NET assemblies from Oracle. I also had to purge all the files from the IIS web apps that were using the older assemblies. Now I don't get any conflicts regarding 32 vs 64 bit versions when I debug in IIS Express vs IIS. See the following article.

An Easy Drive to .NET

慵挽 2024-08-22 09:15:44

几天来我遇到了同样的问题,然后我发现 Oracle.DataAccess 在项目的引用列表中可用,但在 bin 文件夹中丢失。所以我把它从参考文献列表中删除并再次阅读。

I was facing the same issue for a couple of days then I figure out that the Oracle.DataAccess is available in the references list of the project, but in the bin folder is missing. So I removed it from the references list and readded again.

执妄 2024-08-22 09:15:44

请将您的 Oracle.DataAccess 注册到 GAC

raProvCfg.exe /action:gac /providerpath:C:\oracle\product\11.2.0\x32\ODP.NET\bin\4\Oracle.DataAccess.dll

OraProvCfg.exe /action:gac /providerpath:C:\oracle\product\11.2.0\x64\ODP.NET\bin\4\Oracle.DataAccess.dll

please register your Oracle.DataAccess to GAC

raProvCfg.exe /action:gac /providerpath:C:\oracle\product\11.2.0\x32\ODP.NET\bin\4\Oracle.DataAccess.dll

OraProvCfg.exe /action:gac /providerpath:C:\oracle\product\11.2.0\x64\ODP.NET\bin\4\Oracle.DataAccess.dll
滥情哥ㄟ 2024-08-22 09:15:44

您可以按照此

https: //docs.oracle.com/health-sciences/inform-62/install/index.htm?toc.htm?214691.htm

注册 Oracle.DataAccess.dll 程序集
您必须将 Oracle.DataAccess.dll 程序集注册到 .NET 版本 2 和版本 4 的全局程序集缓存 (GAC):

  1. 以管理员身份打开命令提示符。

  2. 导航到 %ORACLE_CLIENT_HOME%\ODP.NET\bin\2.x。

  3. 执行以下命令::oraprovcfg.exe/action:gac/providerpath:Oracle.DataAccess.dll

  4. 导航到 %ORACLE_CLIENT_HOME%\ODP.NET\bin\4.x。

    >

  5. 执行以下命令:oraprovcfg.exe/action:gac/providerpath:Oracle.DataAccess.dll

you can follow this

https://docs.oracle.com/health-sciences/inform-62/install/index.htm?toc.htm?214691.htm

Register the Oracle.DataAccess.dll assembly
You must register the Oracle.DataAccess.dll assembly to the Global Assembly Cache (GAC) for .NET version 2 and version 4:

  1. Open a command prompt as an Administrator.

  2. Navigate to %ORACLE_CLIENT_HOME%\ODP.NET\bin\2.x.

  3. Execute the following command:: oraprovcfg.exe/action:gac/providerpath:Oracle.DataAccess.dll

  4. Navigate to %ORACLE_CLIENT_HOME%\ODP.NET\bin\4.x.

  5. Execute the following command: oraprovcfg.exe/action:gac/providerpath:Oracle.DataAccess.dll

长安忆 2024-08-22 09:15:44

就我而言,这是由于选中了“首选 32 位”框。

首选 32 -位

For my case, it was due to this "Prefer 32-bit" box being checked.

Prefer 32-bit

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文