The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    20140508-Delphi-2007--Project-Options--Cannot-Edit-Application-Title-HelpFile-Icon-Theming

    20140430-Fiddler-Filter-Actions-Button-Run-Filterset-now

    20140424-Windows-7-free-disk-space

    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,338 other followers

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 Jeroen Pluimers 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

Via: visual studio 2010 – VisualStudio2010 Debugging – The process cannot access the file … because it is being used by another process – Stack Overflow.

2 Responses to “WinForms UserControl and Visual Studio 2010 debugging – The process cannot access the file … because it is being used by another process – Stack Overflow”

  1. 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 1,338 other followers

%d bloggers like this: