The process cannot access the file because it is being used by another process.

Ever seen the error in the title...the one that happens when you rebuild your project in VS and it says:

Error 1 Could not write to output file Foo.exe' -- 'The process cannot access the file because it is being used by another process. '

This is a very frustrating error that many users have complained to us about in VS 2003. We have spent many hours figuring out these problems and fixing them. In Whidbey, we want to fix any bugs like these - we've fixed known issues from VS 2003, but if you happen to see one of these in Beta2, here's a guide of things to do. Please report the following stuff to us in the bug you open at the Product feedback site:

  1. Are any Visual Designers open? Does closing Visual Designers (and restarting devenv) help?
  2. Install Process Explorer from

www.sysinternals.com. Search for handles open on the output file (Foo.exe/Foo.dll) . Who is holding handles on it?

Is the Object Browser open? Does closing it help? Does closing it and restarting devenv help?

Provide an inventory of all windows (including tool windows) open. Sometimes one of these windows has a component loaded locking the dll.

If you can, please send the solution that repros the problem (if you have a consistent repro).

Are any addins running when this error occurs? Perhaps disabling addins helps?

Hopefully, going through these steps should also help you find a workaround for this annoying issue. Please report it to us if you do see it - we want to fix all of these.

Shaykat