状況は次のとおりです。「TestProject」と呼ぶテスト プロジェクトを使用して単体テストを実行しようとしています。「Class1」および「Project1」と呼ぶ別のプロジェクトのクラスをテストしています。
Project1 は、実行時にさまざまな dll の動的遅延読み込みを行います。これを「TheDynamicDLLs」と呼びます。Project1 は、独自のビルド出力パスに関連するディレクトリを調べることで、これらの dll を見つけます。
問題の最初の部分は、TestProject が Project1 を参照するときに発生します。明らかに、新しくビルドされた Project1.dll を独自のビルド ディレクトリにコピーします。次に、Project1.dll がその場所からの相対パスで TheDynamicDLLs を検索すると、それらを見つけることができません。自分の。
これを修正するために、TestProject の参照に移動し、Project1 参照を右クリックして、そのプロパティを開きました。次に、「ローカルにコピー」を「False」に設定します。また、参照の "Path" プロパティが Project1 のビルド パスと同じであることも確認しました。
今、私は新しい問題を抱えており、それが何であるかさえ理解できません。単体テストを実行するたびに、「System.IO.FileNotFoundException: ファイルまたはアセンブリを読み込めませんでした [Project1 が見つからないアセンブリであるという情報]」というレポートで失敗します。
さらに、単体テストを実行するだけでなく、デバッグしようとすると、例外がスローされたり、文句が出たりすることがないため、問題に関する詳細情報を見つけることができません。テストレポートにも、これ以上役立つ情報はありません。
以下は、機密保持のために名前などを差し替えた完全なテスト レポートです。
Test Name: Class1_Tests
Test FullName: TestProject.TestClass.Class1_Tests
Test Source: c:\Code\Solution1\Tests\TestProject\TestClass.cs : line 175
Test Outcome: Failed
Test Duration: 0:00:00.0348455
Result Message:
Test method TestProject.TestClass.Class1_Tests threw exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Project1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.=== Pre-bind state information ===
LOG: DisplayName = Project1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Code/Solution1/Tests/TestProject/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : TestProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Code\Solution1\Tests\TestProject\bin\Debug\TestProject.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: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Code/Solution1/Tests/TestProject/bin/Debug/Project1.DLL.
LOG: Attempting download of new URL file:///C:/Code/Solution1/Tests/TestProject/bin/Debug/Project1/Project1.DLL.
LOG: Attempting download of new URL file:///C:/Code/Solution1/Tests/TestProject/bin/Debug/Project1.EXE.
LOG: Attempting download of new URL file:///C:/Code/Solution1/Tests/TestProject/bin/Debug/Project1/Project1.EXE.
Result StackTrace: at TestProject.TestClass.Class1_Tests()
ログから、ローカルにコピーしないように明示的に指示したにもかかわらず、TestProject はまだ Project1 の dll を独自の #$%^ing ビルド パスからロードしようとしているようです。(ぐう…)
私は何を間違っていますか?