Unable to copy file -> restart VS2010 after each debuging session
Hello,
I have a project in VS2008, the solution contains a exe some dll's. The exe is loading the dll's. To prevent loading the dll's in designtime I'm using:
if (!DesignerProperties.GetIsInDesignMode(new DependencyObject()))
{
// do not load Dll's
}This works fine in VS2008
and I can debug it as usually.
Loading the same Projekt in VS2010 I can debug it only once. After editing sourcecode and rebuilding VS2010 reports an error:
Error 35 Unable to copy file "obj\Debug\xyz.exe" to "bin\Debug\xyz.exe". The process cannot access the file 'bin\Debug\xyz.exe' because it is being used by another process.
Error 37 Unable to copy file "obj\Debug\abc.dll" to "..\Plugins\abc.dll". The process cannot access the file '..\Plugins\abc.dll' because it is being used by another process.Is there a work around? It is not funny to restart VS2010 after each debuging session.
Roy- Moved byCharles SterlingMSFT, OwnerTuesday, May 26, 2009 5:04 PMMoving as it is not a TFS Question (From:Microsoft Visual Studio Team Foundation Server 2010 Beta 1)
Answers
- Hi Roy,
Thanks for your feedback.
Based on these info, I would believe this as a problem of VS designer or your design-time code specific instead of VS debugger. It is not the problem of the compiler/linker because VS IDE will only launch msbuild+csc.exe+al.exe for the compilation/linking process. Since it is VS IDE instead of compiler/linker locks your dll/exe, it should not be the build system problem.
Since I am not the expert on the design-time development, I would leave the response to other designer experts. Anyway, you'd better post the detailed reproduce code so that they can see what's wrong.
If you can not get a good answer there and you are pretty sure this is a Winform Designer or VS2010 designer bug. You submit the bug with the reproduce project using the link below:
https://connect.microsoft.com/VisualStudio/content/content.aspx?ContentID=12362&wa=wsignin1.0
Thanks.
Jeffrey Tan - MSFT- Marked As Answer byRMxxx Tuesday, June 02, 2009 6:18 AM
- Try unchecking Enable Historic Debugging in Tools | Options | Historical Debugging and see if that fixes it.
Yours,
David Williamson
Microsoft Visual Studio Team System- Marked As Answer byRMxxx Wednesday, June 03, 2009 7:00 AM
All Replies
- Hi Roy,
We're going to try to reproduce the issue on our side to see if we can find a work around (in addition to finding the actual fix). Would you be able to provide us with some addtional information that could help us reproduce the issue?
Is this a fully managed application or are you using native binaries as well?
Is it 32-bit or 64-bit?
Do you have the hosting process enabled?
Have you installed any packages on top of Visual Studio 2010?
Thanks.
Brad Sullivan - Program Manager - Visual Studio Debugger
Hello Brad,
thank you for inquiry. I'm using VS2010 on Vista Ultimate 64bit. The installation is not modified by any additional packages. The VS2010 is shown in the TaskManager as devenv.exe *32.My project is fully (exe and dll's) in C#, managed, with Framwork 4.0, Platform target is x86. I'm not using any native binaries.
The hosting process is enabled.
If I disable the hosting process a security hint appear on starting debugging. But this switch did not really effect on the "unable to copy file"-problem.
I hope I could help.
Roy.- Hi Roy,
Thanks for your detailed info.
I have tried to copy one VS2008 project to another VS2010 beta1 machine and used it for debugging. I did not get this error after changing the source code and restart debugging for more than 1 times. So we can not reproduce this with a new project yet.
Can you try to create a new simple C# console project in VS2008 and try the same steps in VS2010 to see if you can reproduce? This test can help us to identify if this problem is your project specific.
Furthermore, based on this error message, some process is locking your exe/dll in use, so the compiler can not generates the new exe/dll and delete the old ones. An informative way is using Process Explorer to find out which process is locking these files. Below are the steps:
1. Download Process Explorer from the link below(it does not need installation):
http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx
2. Unzip it and right click the procexp.exe and Run it as Administrator
3. Open Find->"Find Handle or Dll..." menu
4. In the pop up dialog, input your locking exe/dll, such as "abc.dll", then click "Search"
Process Explorer will search all processes handle table and dll lists to find out if any process opens handle to this exe/dll. The theory here is that if a process uses exe/dll, it has to open a file handle to this exe/dll or it must load the exe/dll into its process space dll lists.
Please post the result here for further investigation.
Thanks.
Jeffrey Tan - MSFT- Proposed As Answer bywinosvista Saturday, May 30, 2009 9:18 PM
Hi Jeffrey,
thanks for the information to investigate this problem more.
I'm doing the following steps:
0. Start VS2010
1. Load Solution
2. Rebuild Solution
3. Start Program Debugging (No breakpoint neccessary)
4. Close Program
5. Make a small editing in a *.cs of dll
6. Build the dll again7. -> Error 11 Unable to copy file "obj\Debug\abc.dll" to "..\Plugins\abc.dll". The process cannot access the file '..\Plugins\abc.dll' because it is being used by another process. abc
Now the ProcessExplorer information:
In the DLL-View of devenv.exe I find my xyz.exe and the abc.dll.
Thanks
Roy- Hi Roy,
Thanks for your feedback.
Based on these info, I would believe this as a problem of VS designer or your design-time code specific instead of VS debugger. It is not the problem of the compiler/linker because VS IDE will only launch msbuild+csc.exe+al.exe for the compilation/linking process. Since it is VS IDE instead of compiler/linker locks your dll/exe, it should not be the build system problem.
Since I am not the expert on the design-time development, I would leave the response to other designer experts. Anyway, you'd better post the detailed reproduce code so that they can see what's wrong.
If you can not get a good answer there and you are pretty sure this is a Winform Designer or VS2010 designer bug. You submit the bug with the reproduce project using the link below:
https://connect.microsoft.com/VisualStudio/content/content.aspx?ContentID=12362&wa=wsignin1.0
Thanks.
Jeffrey Tan - MSFT- Marked As Answer byRMxxx Tuesday, June 02, 2009 6:18 AM
- Try unchecking Enable Historic Debugging in Tools | Options | Historical Debugging and see if that fixes it.
Yours,
David Williamson
Microsoft Visual Studio Team System- Marked As Answer byRMxxx Wednesday, June 03, 2009 7:00 AM
- Thanks David,
it seems that the disabling of this option solve the problem.
With best regards
Roy - Sorry to hear that you ran into this issue with the historic debugger. This has since be addressed and will not be present in the shipping product.
Thanks,
Bill - Hi Roy,
We believe that we have been able to address this issue since Beta1 shipped, however it is not something that we are able to consistently reproduce. We would really like to verify that we have resolved this issue, so if you would able to provide us with a brief code sample that produces this behavior for you on a consistent basis it would be very valuable in helping us assure that we have correctly resolved this bug.
Thanks,
Andrew Hall
Visual Studio Debugger- Edited byAndrew B Hall - MSFT Friday, June 12, 2009 10:06 PM
- I was having the "unable to copy file" problem too using VS2010 Beta 2. I had instaniated a web service but did not dispose of the object during form close. Once I added the dispose, the problem was solved.
- Same for me. VS2008 project which never had any problems - using beta 2 of VS2010 and when I make use of the web service during debug I get this error the next time I try to run it. Using Dispose seems to do the trick.
- Having the same issue but with VS 2010 Pro - so no IntelliTrace/Historical Debugger. Any idea why the friggin file is always locked?
My observation is, that it is working a couple of time (two or four times) and then it is starting to lock my WinForms executable.
cheers, Stefan http://www.code4ward.net Home of Royal TS and LogSmith for OpsMgr


