visual studio C# locking .exe file

I am working on a gui app written in C# using visual studio and I am running into a really annoying bug where when I make changes to the application, it debugs correctly the first time I try to debug it, but when I try to debug the application again I get an error say that it can't copy an exe file from the obj directory to the bin directory.

Restarting visual studio fixes this.

It's really annoying to have to restart all the time though. There seem to be a number of posts online about this, but no one seems to have found the solution. Has anyone here been able to resolve this?

Answers


try VSCommands 2010 extension. When you get the error again righ click on the message in error list and click 'Apply Fix' from context menu. This will tell you which process sits on the file and allow you to terminate it.

In a longer run, it may be that you have a background thread running which doesn't terminate when application finishes.


I have the same problem. I found in another thread (can't remember which) that for some unfathomable reason, you can change the assembly version declared in your AssemblyInfo.cs files from

AssemblyVersion("1.0.*")

into

AssemblyVersion("1.0.0.0")

Or some other explicit version, and the problem goes away. This worked fine for me. However, I would like a solution that would allow me to use the wildcard version as well. Or an explanation of why the assemblyversion causes the file to be locked.


is this a service? you may have to installutil -u prior to recompiling


In my case it was the Anti Virus software Avira antivir. When I added the publishing folders in the exceptions the problem went away. Avira usually takes a long time to scan stuff in the background, apparently locking exe files before they can be overwritten. After the scan the file is unlocked. When my develop/test cycle is less than 30 seconds (which it often is) it will trigger this error after retrying 10x.


Need Your Help

Can't connect to localhost: Using CasperJS for ExpressJS application test suite

node.js express phantomjs casperjs

I seem to be having a very basic issue with using CasperJS to create a functional test suite for an ExpressJS based web application. I can't seem to connect to t

Google Charts - Change chart x-axis dynamically when bounded to a control

javascript google-visualization google-chartwrapper

I have 5 columns of data in my DataTable where column 0 and 4 have different x-axis values I would like to plot against and columns 1-3 have the y-axis data to plot.