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