Why is referenced dll getting locked while debugging under Resharper/MSTest?

a 夏天 提交于 2019-12-10 17:49:25

问题


I have an integration test for a method in assembly A. Assembly A references assembly B via project reference. I run them under the Visual Studio 2010 debugger in a Resharper 6.1 unit testing scenario. The testing engine is Microsoft's native MSTest.

I get the infamous

The process cannot access the file ...\B.dll because it is being used by another process.

message. I have verified that no other process has a handle on that file (e.g. via Sysinternal's Process Explorer).

Running the test out of the debugger works fine. Any ideas why it happens under the debugger and what I can do to fix it?


回答1:


I have seen a similar situation, and found in the task manager that vtest.discoveryengine.exe and vtest.executionengine.exe were still alive. I killed both, which solved the problem.




回答2:


Building upon Sébastien's answer, I added a pre-build step to my test project to automatically kill any vstest.* executables still running. The following pre-build command worked for me:

taskkill /f /im vstest.*
exit 0

The exit 0 command is at the end to prevent build failure when there are no vstest.* executables running.




回答3:


Building upon @mrtumnus' answer and the answer here, I added a pre-build step to my test project to automatically kill any vstest.* executables:

START taskkill /f /im vstest.*

Using START instead of exit 0 so it doesn't give an error if the task isn't running. (It does open a command window, though, which is a bit annoying).



来源:https://stackoverflow.com/questions/13278846/why-is-referenced-dll-getting-locked-while-debugging-under-resharper-mstest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!