VS2010 does not always release DLLs before creating

I occasionally have a problem when creating with Visual Studio 2010. Sometimes it refuses to build with an error message, for example:

Error 102 Failed to copy the file "xxxxx \ Debug \ Services.dll" to "bin \ Debug \ Services.dll". The process cannot access the file 'bin \ Debug \ Services.dll' because it is being used by another process.

The only tool I found was to restart Visual Studio. Closing a solution is not enough. I tried to find the culprit in Process Explorer, as I suspected that one of my own threads was not closing properly. However, the process is devenv.exe, that is, Visual Studio itself. Also, I get this symptom only with VS 2010, even when I build modernized VS 2008 projects. I have never encountered this problem with the same projects in VS 2008.

I have many WPF user controls, and I have a theory that a WPF designer sometimes holds on to a control dependent dll when he needs to free them for assembly. The theory has not been established, since it is a periodic problem, and sometimes it arises if it is not open. I also have the same problem for a windows forms project. Sometimes I get a day without a blocked dll. Sometimes this is any other assembly or so.

I asked Microsoft about the problem, and they told me to dump Visual Studio and debug the dump. I did not find this good advice.

Has anyone experienced something similar? This is really annoying.

Update 1

Since this seems like a Visual Studio bug, and Microsoft replied that they did not intend to do anything, I would like to encourage everyone who works with user controls to vote for this error on connect.microsoft.com.

The error is reported here: https://connect.microsoft.com/VisualStudio/feedback/details/587281 and here https://connect.microsoft.com/VisualStudio/feedback/details/568672

Update 2 I hacked into a simple Visual Studio macro that closes all .XAML files before creating. So far I have not seen a lock with this macro. Add the following macro to Visual Studio and assign it in a short time. Perhaps, perhaps this will not fix the problem.

Imports System Imports EnvDTE Imports EnvDTE80 Imports EnvDTE90 Imports EnvDTE90a Imports EnvDTE100 Imports System.Diagnostics Public Module CloseXamlAndBuildModule Sub CloseXamlAndBuild() For Each myDocument As EnvDTE.Document In DTE.Documents If myDocument.Name.EndsWith(".xaml") Then myDocument.Close() End If Next DTE.Solution.SolutionBuild.Build() End Sub End Module 
+4
source share
4 answers

Finally, I found a stable working solution. I realized that the source of the problem was the initialization of the code in the designers of WCF services and WPF controls. After cleaning the designers from any dependencies on other assemblies, everything was in order.

+3
source

Try using the VSCommands plugin . He has the option "Apply the patch", which will allow you to close any process that locks the file (most often it is a vshost process that can be killed).

alt textalt text

+2
source

This is a pretty persistent complaint about VS2010, although it is not widespread. I have not yet seen a good diagnosis. The feedback element to view is this one , it seems to be a collector for most duplicates. Solving the problem faster will likely require opening a case at Microsoft Support.

+1
source

I actually reported this issue to Microsoft Connect a while ago, but did not check the problem after a while. My initial report for Microsoft is here .

Among the comments is a way to reproduce the problem with user controls (as I suspected).

Microsoft simply responded with the standard "thank you for your feedback, your proposal does not meet the criteria that need to be addressed." Thanks, Microsoft. I think I just have to live with restarting Visual Studio a couple of times per hour.

0
source

All Articles