MSB3021 Is Back (File Locked by Other Process), With Added Weirdness!

I remember seeing this issue years ago. I think there were two separate cases where it somehow crept up, one around the scenario of configuring several projects in VS to build into the same output directory, the other to do with the “Visual Studio hosting process”. Maybe I’m wrong about the second. Anyway. Now I’m seeing this issue with some regularity in VS 2010 RTM. There doesn’t seem to be a common denominator to the projects that bring this up – I’ve seen it in large-ish Windows Forms apps as well as in several different small demo projects from my presentations (which are usually command line programs). What happens is quite odd. Usually I’m in full flow, running the app, seeing something odd, exiting and correcting the problem in code, hitting Ctrl-F5 and boom! VS claims it can’t copy the output exe file to its target location because it is locked by another application.

Not true, quite obviously, since there is really no other application on my system interested in the file. There doesn’t seem to be a reliable workaround at this point – usually I try to rebuild the program a few times, and after a little while (usually exactly a second after I’ve hit Shift-Ctrl-B eight times and I’m now off looking for Process Explorer in the hope of finding the offending locker) it suddenly works just fine. Very odd. Even weirder is that when I actually manage to run Process Explorer in time, its handle search feature doesn’t even find the file in use at all! How is that even possible?

While I’m writing this, I had one idea. I have started using TrueCrypt to store lots of stuff in encrypted virtual drives. I’ve used it for a good long while now and I haven’t really had any problems with it at all, but maybe it’s something to check out. Not sure how that checking out is going to work, but check out I will. I’ll keep you posted. But if you have any ideas, please let me know.

Sorry, this blog does not support comments.

I used various blog hosting services since this blog was established in 2005, but unfortunately they turned out to be unreliable in the long term and comment threads were lost in unavoidable transitions. At this time I don't want to enable third-party services for comments since it has become obvious in recent years that these providers invariably monetize information about their visitors and users.

Please use the links in the page footer to get in touch with me. I'm available for conversations on Keybase, Matrix, Mastodon or Twitter, as well as via email.