11

I am in charge of testing VS 2015 and how it works with our current applications for my employer. We currently use VS 2013 for everything we have, so I know there are no issues there. The problem I am having is that it appears the vshost.exe isn't terminating correctly or something. I have not narrowed down the exact issue but so far that is what I believe.

Here is how I get my error:

  1. Run my app in debug
  2. Open a few windows
  3. Hit the "Stop Debug" button (the little red square)
  4. Clean Solution
  5. Rebuild Solution

After my rebuild I get the following errors in the EXE:

Error       Could not copy "obj\Debug\APP.exe" to "..\..\bin\APP.exe". Exceeded retry count of 10. Failed.  
Error       Unable to copy file "obj\Debug\APP.exe" to "..\..\bin\CRM.exe". The process cannot access the file '..\..\bin\APP.exe' because it is being used by another process. 

If I open the Task Manager and manually end the vshost.exe process I can successfully rebuild again, no issues. If I take the same steps, however, I am no longer able to build.

I tested these steps in 2013 and did not have an issue.

Also note that disabling the "Enable the Visual Studio hosting process" does alleviate the issue, however I do not want to disable this option.

Has anyone else had this issue? I know we are still early in release. Any suggestions/solutions to try? Is it possible there is something wrong in our code (which I highly doubt since I would then get the error in 2013, most likely).

Thanks for any help I receive!

EDIT: This is a WPF application written in .Net 4.0 using C#. Also, I have verified that the issue also occurs if I exit the application normally (IE I open a window then close it with the shutdown mode on LastWindowClosed)

SECOND EDIT: This is a new issue that presented itself in Visual Studio 2015 with the addition of the new live diagnostic tools.

Carson
  • 1,169
  • 13
  • 36
  • Possible duplicate of [I can't kill MyApp.vshost.exe](https://stackoverflow.com/questions/4314436/i-cant-kill-myapp-vshost-exe) – Michael Freidgeim Jun 17 '17 at 07:31
  • @MichaelFreidgeim This is not a duplicate. The versions of visual studio affected are separated by 5 years and the features that cause this bug were new to version 2015, so this bug is not even possible in older versions. The fixes in the older versions (disabling vshost) do work, but there are other, less intrusive fixes as stated in my answer. – Carson Jun 18 '17 at 17:27

2 Answers2

10

I have found that if I have the "Enable Diagnostic Tools while debugging" option enabled in the debug settings I get this error. If I disable this option, the error goes away. I am not sure if this is a bug in Visual Studio but I would assume so, unless I need to do something else to shut them down properly. If anyone has comments or concerns, feel free to leave a note.

Carson
  • 1,169
  • 13
  • 36
1

Probably late for the original question (and I see that he had a workaround), but as per MSDN, VSHOST.exe is only an enabler for improving Debug performance or facilitates scenarios such as partial trust debugging. If you do not need that support or can bear the cost of starting a process and attaching the debugger on each debug session, go ahead and disable the hosting process from project designer -> Debug -> Clear the box "Enable Visual Studio hosting process"

Sudhanshu Mishra
  • 6,523
  • 2
  • 59
  • 76