我試圖運行一些單元測試,執行一些SQL命令直接到Oracle數據庫,我得到當單元測試開始以下例外:System.IO.FileNotFoundException:無法加載文件或程序集'Oracle.DataAccess,...當運行單元測試
Testmethod1拋出異常:
System.IO.FileNotFoundException:未能加載文件或程序集「Oracle.DataAccess,版本= 4.112.3.0文化=中性公鑰= 89b483f429c47342'或其依賴項之一。該系統找不到指定的文件。
我有Oracle.DataAccess
在項目引用(通過NuGet添加),我有我已經安裝了Oracle數據提供程序。
我甚至有一些其他項目使用Oracle.DataAccess
在本機上運行沒有問題。似乎只有Microsoft.Net單元測試框架(MSTest)無法加載程序集。
這是融合日誌查看器所採取的日誌:
*** 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數據提供程序是64位版本。
- 參考已有
Copy Local=True
打開融合日誌記錄,看看是否可以幫助您找出丟失的文件:http://www.hanselman.com/blog/CommentView.aspx?guid=3654c8f3-c5c3-4dee-a01f-c9a8da3ef2fa –
Didn'不瞭解它。謝謝。我只是將其添加到問題 – mmutilva
您的測試是否以32位過程運行? –