Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 639
Kit Avatar asked Dec 09 '22 19:12

Kit


2 Answers

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.

like image 162
mrtumnus Avatar answered Feb 16 '23 00:02

mrtumnus


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.

like image 29
Sébastien Barré Avatar answered Feb 16 '23 00:02

Sébastien Barré