gpt4 book ai didi

oracle - System.IO.FileNotFoundException : Could not load file or assembly 'Oracle. DataAccess, ... 运行单元测试时

转载 作者:行者123 更新时间:2023-12-04 19:08:35 33 4
gpt4 key购买 nike

我正在尝试运行一些单元测试,这些单元测试直接对 Oracle 数据库执行一些 SQL 命令,并且在单元测试开始时出现以下异常:

Testmethod1 threw exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.



我有 Oracle.DataAccess在项目引用(通过 NuGet 添加)中,我已经安装了 Oracle 数据提供程序。

我什至还有一些其他项目使用 Oracle.DataAccess在这台机器上运行没有问题。似乎只有 Microsoft.Net 单元测试框架 (MSTest) 无法加载程序集。

这是从 Fusion Log Viewer 中获取的日志:
*** Assembly Binder Log Entry  (23/08/2013 @ 04:50:07 p.m.) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\QTAgent32_40.exe
--- A detailed error log follows.

=== Pre-bind state information ===
LOG: User = ...
LOG: DisplayName = Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342
(Fully-specified)
LOG: Appbase = file:///...C:/<solution_folder>.../TestResults/.../Out
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = QTAgent32_40.exe
Calling assembly : ...<project_name>..., Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\...<solution_folder>...\TestResults\...\Out\...<project_name>....DLL.config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/...<solution_folder>.../TestResults/.../Out/Oracle.DataAccess.DLL.
LOG: Attempting download of new URL file:///C:/...<solution_folder>.../TestResults/.../Out/Oracle.DataAccess/Oracle.DataAccess.DLL.
LOG: Attempting download of new URL file:///C:/...<solution_folder>.../TestResults/.../Out/Oracle.DataAccess.EXE.
LOG: Attempting download of new URL file:///C:/...<solution_folder>.../TestResults/.../Out/Oracle.DataAccess/Oracle.DataAccess.EXE.
LOG: All probing URLs attempted and failed.

它指出在 GAC 中未找到该程序集,但我确实找到了它: C:\Windows\Microsoft.NET\assembly\GAC_64\Oracle.DataAccess\v4.0_4.112.3.0__89b483f429c47342\Oracle.DataAccess.dll\
另外值得注意的是,上面的日志显示 QTAgent32_40.exe即使我在 Visual Studio 菜单中选择了 TEST -> Test Settings -> Default Processor Architecture -> X64 .在这样做之前,我收到了一个 BadImageFormatException反而。

附加说明:
  • 我安装的 Oracle Data Provider 是 64 位版本。
  • 引用文献已有 Copy Local=True
  • 最佳答案

    发现问题了。

    有一个 .testsettings 文件强制测试在 32 位模式下运行 不管我选择 TEST -> Test Settings -> Default Processor Architecture -> X64 .

    奇怪的是,如果我选择 X86,我会得到正确的 BadImageFormatException在运行时,如果在 .testsettings 文件中强制使用架构,我会得到 FileNotFoundException ,这有点误导。

    关于oracle - System.IO.FileNotFoundException : Could not load file or assembly 'Oracle. DataAccess, ... 运行单元测试时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18410467/

    33 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com