疑わしいコードを実行するテストを実行した後。Nunit (具体的には nunit-agent.exe) が終了するまで、Visual Studio でアセンブリを再構築できません。
エラーは次のとおりです。
Could not copy "C:\path\MyTests\MyTests.dll" to "bin\Debug\MyTests.dll".
Exceeded retry count of 10.
Unable to copy file "C:\path\MyTests\Debug\MyTests.dll"
to "bin\Debug\MyTests.dll". The process cannot access the file
'bin\Debug\MyTests.dll' because it is being used by another process.
現在の回避策は、nunit を閉じ、再構築してから、nunit を再度開く (そしてテストする) ことです。痛い
レッドニシンは、これがボリューム シャドウ コピーの問題か、nunit プロジェクトのプロジェクト ベース パスの設定であると考えていました。これらではありません。それがこのコードです。
AppDomain dom = AppDomain.CreateDomain("some");
string fullPath = Assembly.GetExecutingAssembly().CodeBase
.Replace("file:///", "").Replace("/", "\\");
AssemblyName assemblyName = new AssemblyName();
assemblyName.CodeBase = fullPath;
Assembly assembly = dom.Load(assemblyName);
Type type = assembly.GetType("ClassName");
IMyInterface obj = Activator.CreateInstance(type) as IMyInterface;
obj.ActionMessage(param1, param2);
これは処分の問題だと思ったので、IDisposable を実装し、クラス「ClassName」に必要なコードを追加しました。動作しませんでした。
この問題を解決するにはどうすればよいですか?