Windows 7 の Visual Studio 2012 で C# コードを作成しています。私のソリューションにはいくつかのプロジェクトが含まれています。
最近、ソリューションに新しいプロジェクトを追加し、ソリューション内の他の 2 つのプロジェクト (そのうちの 1 つはスタートアップ プロジェクト) の参照にこの新しいプロジェクトの dll を追加しました。新しいプロジェクト自体は、私のソリューションに含まれていない他のいくつかのプロジェクトを参照しています。
ソリューションでプロジェクトをビルドすると問題なく動作しますが、プログラムを (デバッグまたはリリースで) 実行しようとするとエラーが発生します。エラーは次のとおりです。
System.IO.FileNotFoundException was caught
HResult=-2147024894
Message=Could not load file or assembly 'ABCD, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Source=NP
FileName=ABCD, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
FusionLog==== Pre-bind state information ===
LOG: User = MyCompany\MyName
LOG: DisplayName = ABCD, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
(Fully-specified)
LOG: Appbase = file:///C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : NP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\MyName\Documents\Visual Studio 2012\Projects\MyProgram\Analysis\bin\Debug\Analysis.vshost.exe.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:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/ABCD.DLL.
LOG: Attempting download of new URL file:///C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/ABCD/ABCD.DLL.
LOG: Attempting download of new URL file:///C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/ABCD.EXE.
LOG: Attempting download of new URL file:///C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/ABCD/ABCD.EXE.
StackTrace:
at NewProject.DATA.SetType(NP np, String code, OrderType orderT, MODEL MODELv)
at NewProject.DATA.SetData(NP np, String no, String type, String law, String time, OrderType orderT, MODEL MODELv)
InnerException:
分析は私のスタートアップ プロジェクトです。NewProject は、最近ソリューションに追加したプロジェクトです。ABCD.dll は NewProject で参照されていますが、プロジェクト ABCD はソリューション自体の一部ではありません。
このエラーでは、AppBase が file:///C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/ であると言われています。
ただし、NewProject の ABCD 参照を見ると、次のように書かれています。
Assembly ABCD
C:\Users\MyName\Documents\Visual Studio 2012\Projects\np\bin\ABCD.dll
確かに、エラーに書かれている AppBase アドレスに ABCD.dll はありません。しかし、私はそれがそこにあるとは決して言いませんでしたし、これがどこから来たのかわかりません.
エラーが表示された AppBase アドレスに ABCD.dll を入れようとしました。しかし、NewProject と (その後) スタートアップ プロジェクトの Analysis を再構築するたびに、ABCD.dll が C:/Users/MyName/Documents/Visual Studio 2012/Projects/MyProgram/Analysis/bin/Debug/ から消えます。
私はVisual Studioを初めて使用します。新しいプロジェクトを追加するときに何か間違ったことをしたのかもしれませんが、それが何であるか理解できません。この問題を解決する方法についてアイデアをお持ちの方がいらっしゃいましたら、お気軽にご相談ください。