Outer Level


Visual Studio: Could not write to output file

One of my all-time favorite Visual Studio 2003 bugs occurs when trying to build a solution with multiple projects that all reference a base library.

If any code changes in the base library, the very next build will always fail with the following error:

Could not write to output file '[path-to-project]\obj\Debug\[file-name].dll' -- 'The process cannot access the file because it is being used by another process. '

What’s really pathetic is that the “other process” is Visual Studio itself. Something about the way the build works causes the process to step on itself everytime the base library needs to be compiled.

The only way I’ve found to get around the issue is to close Visual Studio, manually delete the library’s /obj and /bin directories. Then reopen Visual Studio and rebuild.

Really, friggin annoying. I can’t believe this hasn’t been found and fixed already.

2 Responses to “Visual Studio: Could not write to output file”

  1. jason Says:

    An other work around is to switch to ‘Release’ configuration – wait while it does it’s thing – delete the obj directory and then switch back to ‘Debug’. This of course assumes you were working with Debug to begin with. This is slightly quicker than closing the process but equally as annoying …

  2. Jon Trainer Says:

    Thanks Jason. I was not working in ‘Release’ mode so this would probably work. But, doesn’t this strip the debug info that the debugger uses? I also have #if statements relying on the DEBUG value to be set for debugging code. These also would cease working.