System.IO.FileNotFoundException:无法加载文件或程序集'Oracle.DataAccess,...运行单元测试时

mmu*_*lva 5 oracle ado.net mstest visual-studio-2012

我正在尝试运行一些单元测试,直接执行一些SQL命令到Oracle数据库,并在启动单元测试时得到以下异常:

Testmethod1抛出异常:
System.IO.FileNotFoundException:无法加载文件或程序集'Oracle.DataAccess,Version = 4.112.3.0,Culture = neutral,PublicKeyToken = 89b483f429c47342'或其依赖项之一.该系统找不到指定的文件.

我有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.
Run Code Online (Sandbox Code Playgroud)

它声明在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

mmu*_*lva 5

发现了问题.

有一个.testsettings文件强制测试以32位模式运行,无论我选择什么TEST -> Test Settings -> Default Processor Architecture -> X64.

奇怪的是,如果我选择X86获得正确的BadImageFormatException在运行,而如果建筑被强制在.testsettings文件我得到的FileNotFoundException,这是一个有点误导.