WinForms UserControl and Visual Studio 2010 debugging – The process cannot access the file … because it is being used by another process – Stack Overflow
Posted by jpluimers on 2011/12/13
When doing WinForms development in Visual Studio 2010 (including SP1), be aware of a bug with UserControls that hamper debugging; sometimes you get an error like this:
Error 9 Unable to copy file "obj\x86\Debug\MyProject.exe" to "bin\Debug\MyProject.exe". The process cannot access the file 'bin\Debug\MyProject.exe' because it is being used by another process.
When using SysInternals’ Process Explorer to see which process has handles open to MyProject, you will see that devenv.exe (The Visual Studio IDE) is the culprit: sometimes it has a lot of handles open.
The workaround is simple: close all UserControls before debugging your WinForms application.
A real pity, as UserControls are a very useful feature when developing software (many platforms use the same paradigm, .NET certainly wasn’t the first to introduce it, and it is available in for instance WPF as well).
Note that there are other causes of the same error message, but for me this was the issue.
–jeroen






gaddlord said
How likely is that Delphi will allow having components written in the same project and available in the component pallete as in VS?
Currently (being very frustrated with the separate packages) I simply started to initialize all of my custom controls with code.
I would like simply to have a new Page called with the name of the project they are declared in and be able to drag and drop them without having to go int the package thing.
P.S> And yes I do not care that design time support will be compiled into my executable.
jpluimers said
Very likely. It just magically works in Delphi: I can have anything that ends up in the Delphi component palette open in the IDE and debug the client app fine.