Tôi đang cố gắng chạy một số kiểm tra đơn vị thực hiện một số lệnh SQL trực tiếp đến cơ sở dữ liệu Oracle và tôi nhận được ngoại lệ sau khi kiểm tra đơn vị được bắt đầu:System.IO.FileNotFoundException: Không thể tải tệp hoặc lắp ráp 'Oracle.DataAccess, ... khi chạy thử nghiệm đơn vị
Testmethod1 ném ngoại lệ:
System.IO.FileNotFoundException: không thể tải tập tin hoặc lắp ráp 'Oracle.DataAccess, Version = 4.112.3.0, Văn hóa = trung tính, PublicKeyToken = 89b483f429c47342 'hoặc một trong các phụ thuộc của nó. Hệ thống không thể tìm thấy các tập tin được chỉ định.
Tôi có Oracle.DataAccess
trong tài liệu tham khảo dự án (được thêm qua NuGet) và tôi đã cài đặt Nhà cung cấp dữ liệu Oracle.
Tôi thậm chí còn có một số dự án khác sử dụng Oracle.DataAccess
chạy trong máy này mà không gặp sự cố. Có vẻ như chỉ có Microsoft.Net Unit Test Framework (MSTest) không thể tải assembly.
Đây là log lấy từ 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.
Nó khẳng định việc lắp ráp không được tìm thấy trong GAC, nhưng tôi đã tìm thấy nó: C:\Windows\Microsoft.NET\assembly\GAC_64\Oracle.DataAccess\v4.0_4.112.3.0__89b483f429c47342\Oracle.DataAccess.dll\
Nó cũng đáng chú ý là các nhật ký trên cho thấy QTAgent32_40.exe
mặc dù tôi đã chọn trong menu Visual Studio TEST -> Test Settings -> Default Processor Architecture -> X64
. Trước khi làm như vậy tôi đã nhận được một BadImageFormatException
thay thế.
Ghi chú thêm:
- Nhà cung cấp dữ liệu Oracle mà tôi đã cài đặt là phiên bản 64 bit.
- Các tài liệu tham khảo đã có
Copy Local=True
Bật ghi nhật ký tổng hợp để xem liệu có giúp bạn tìm ra tệp nào bị thiếu hay không: http://www.hanselman.com/blog/CommentView.aspx?guid=3654c8f3-c5c3-4dee-a01f-c9a8da3ef2fa –
Didn ' Tôi biết về nó. Cảm ơn. Tôi vừa thêm nó vào câu hỏi – mmutilva
Các thử nghiệm của bạn có đang chạy dưới dạng quy trình 32 bit không? –