Error Creating Debug Information - Code Won't Compile - c#

I'm using VS 2008. When ever I make a change in my code and try to compile I get the following error:
Error 7 Unexpected error creating
debug information file 'C:\Documents
and Settings\jbezanson\My
Documents\MyProjects\DispatchBoard\DispatchBoard\obj\Debug\DispatchBoard.PDB'
-- 'C:\Documents and Settings\jbezanson\My
Documents\MyProjects\DispatchBoard\DispatchBoard\obj\Debug\DispatchBoard.pdb:
The process cannot access the file
because it is being used by another
process. ' DispatchBoard
Using Process Explorer, it is always devenv.exe that is locking the file. If I run in Release mode this does not happen. It started 2 days ago when I started a WPF application, and since then it happens with every application I work on.
The only info I could find from Google was referring to a bug in VS 2003.
Anyone else have this problem? How do I fix it? It is getting very annoying having to kill the file handle every time I want to compile.

If you have multiple instances of VS open, close other instances (apart from the one you are trying to compile) - this may resolve the issue.

When I have problems with locked files, I use Unlocker. (If you tried everything and it's not working, try this ;)
In case of broken link, here's a mirror.

Have you tried closing VS, deleting obj folder then restarting VS?

I had the same problem this morning and noticed that I had another project open that had a reference to the one that would not compile or debug. I removed the reference (as I didn't actually need it) and it was fine.

I changed the 'StartUp Project' of my solution to a project without reference to the locked file's project.
This solved the issue for me using VS 2010 SP1.
(Process Explorer said msvsmon.exe (started by devenv.exe) locked the pdb file.
After changing the startup project the processes msvsmon.exe and .vshost.exe disappeared and so did the file handle.)
Alex Clark, thank you for pointing me in the right direction.

The only thing that worked for me is to remove the optimizeCompilations="true" attribute from on the compilation element in my Web.Config file.
Compilation time may be a little longer, but it worked well.

To avoid that problem just open the project properties, go to Debug tab an untick "Enable the Visual Studio hosting process"

I had this issue today. In my case, I had just grabbed the data from my company's source control and instantly hit this issue when I tried to compile the project. The issue ended up being that the \bin folder was set to Read Only. To solve the issue, I just made the folder not Read Only.

I just came across the same problem today. And then I realized what went wrong: I had couple of Visual Studio windows opened at the same time, and one of them was in debug mode.
When I stopped debug mode in that one, the problem was solved.
That happens when you have a "fistfull of VS windows" opened.

Right Click The Folder that contains debug .pdb and uncheck the folders read-only propertys then ok. thats it.

This works for me with web projects in Visual Studio Express 2012 for Web:
Press F5 to begin debugging
"Do you want to execute last successful build?" - hit YES
At this point you could try a request - not sure if this step is necessary
Hit the stop button
Recompile successfully

I have solved a similar problem by adding these lines as a pre-build event:
if exist "$(TargetPath).locked" del "$(TargetPath).locked"
if exist "$(TargetPath)" move "$(TargetPath)" "$(TargetPath).locked"
With proper modifications, it might help your problem.

Since you say you have it on all applications you work on it sounds like a more global problem. You could try and reinit the vs2008 by writing
devenv.exe /setup
Edit: link to command line options

This worked for me. What I done was that close my visual studio and delete the .suo file and then re-open the solution. The locking should be disappeared now. Cheers.

Old topic, but something that worked for me. I had 2 projects in my solution, a class library type project and a windows form project. The windows form project was referencing the compiled binary and not the project itself in my case which was causing the lock. After changing the reference to the class library project, it worked properly.

Not need to restart or delete the file.Deleting will not be possible , you will get error message. Just rename the file and that is enough.
VS2010 will create another file for you as it wont find the origional. :)

I had the same issue from time to time. Usually no problem but once in a while... This particular time, it was impossible to work. I would shut the application down, and even that didn't work most of the time. I saw this post and a person said they had no issues until they started a WPF application. I was playing music (radio station) in the background with Windows 8 "Music" app. I had the idea that it was a Microsoft App built with Visual Studio. Once I stopped playing music, I never encountered the error. If you are reading this, see if you have any Microsoft apps running.

I also had the same issue. Tried all the suggestions above with no luck. I eventually change the Build Configuration from Debug to Release, the solution built...

This problem started occurring for me after changing from Cassini to IIS Express as my platform for debugging.
Cassini was much better than IIS Express but doesn't properly support the Integrated pipeline. IIS Express is hopeless.
This seems to be some sort of race condition in Visual Studio or IIS Express. It is nothing to do with one project locking another project - the locks are coming solely from the activity of the web application's build process.
Anyways, none of the above solutions worked for me. Unlocker doesn't seem to be supported for Windows 8 anymore. So instead I tried LockHunter. What I do is keep the LockHunter app open all day. If I get a complaint about some file being locked I copy and paste the file path into LockHunter then try again. This usually sorts out the problem but sometimes takes a few attempts.

Related

Visual Studio 2015 and uwp development - User-Mapped section error and CopyWin32Resources error

Continuing with some UWP development and 2 things keep happening with visual studio and I can't work out if its a VS2015 bug, the fact that I am deploying to a windows Mobile 10 device or something else.
Randomly when I try to build or deploy to my device I get either.
Could not copy "obj\ARM\Debug\MyApp.exe" to "bin\ARM\Debug\MyApp.exe". Exceeded retry count of 10. Failed.
Unable to copy file "obj\ARM\Debug\MyApp.exe" to "bin\ARM\Debug\MyApp.exe". The requested operation cannot be performed on a file with a user-mapped section open.
or I get
CopyWin32Resources failed with exit code 500
Seems to be random and I can't nail down what is causing either. Googling didn't really help. Some said Anti-virus but disabling mine did nothing. Some said it was something to do with Visual Studio Achievements Extension but I don't have it installed.
Anyone know the cause or a fix? Making development difficult when I can't deploy.
UPDATE: Ok so the first set of errors is more related to Windows 10 I think. When the error appears again I try to manually copy the file and when I do I receive similar error in explorer.
error 0x800704c8: the requested operation cannot be performed on a file with a user-mapped section open.
can you try those things:
Close all other VS windows except one.
Clean the project you works on.
Try build project. If you get same errors, close all VS windows.
Delete 'bin' and 'obj' folders.
Open VS again and try building your project.
Then try deploying your project.
I know you might have found a fix already. But I had the same error after installing new emulators for my uwp application, after installing these emulators I seem to have gotten those errors. I thought uninstalling these emulators would be the fix, but was not. Now I run my program without restoring any missing packages and it seems to be the fix.
For anyone still facing the CopyWin32Resources Error on Windows, try uninstalling CbDefense (both Carbon Black Sensor and CB Defense Sensor 64bit). To much disbelief, this solution suggested by Microsoft resolved the issue for me!
I got this problem whenever I have my project in a folder that is synced by something like Dropbox. Pausing Dropbox always fixes the problem for me.
Fixed the problem. Moved the project out of the Visual Studio Project folder in My documents folder and into a projects folder on the C Drive. None of the errors have returned so I am guessing this is a windows 10 issue.

Can't built my Console Application

From time to time I receive this error message when I'm debugging my Console Application:
The process cannot access the file 'bin\Release...' because it is
being used by another process. Exceeded retry count of 10. Failed.
The fact is that it's not running and Visual Studio keeps showing this message, and so I have to restart it and build it again.
The process is NOT running, so there is no reason to receive this error.
Does anyone know why this is happening?
Verify that nothing has changed the file permissions, and the file isn't read-only. Verify that you cannot delete the file yourself. If so then yes, something is blocking it.
Download handle.exe, which is a command-line tool that shows you what process is locking a file.
If handle.exe says nothing is using your file, or it says devenv.exe is using it, then I think you have hit that intermittent bug in Visual Studio. Your only option is to restart Visual Studio. If you do a google search for "used by another process" with site:connect.microsoft.com you will find that this bug gets reported, then fixed, then reported, then fixed - over many years. Personally, I have had this happen most often on VS2010 using WPF projects. It has yet to happen to me on VS2013. So upgrading might help.
Here is my Google search.
If the process is not running, I suppose Visual studio is the process that uses bin\Release.
If you want to know exactly what the problem is, delete everything in the folder (if possible), the file that will not be deleted will be the one that is used by Visual Studio, this will already be a good indicator.
I'm not sure why you are debugging the release build?
When this happens, it usually is due to being opened i.e. the console window that has ran the app is still open, or it is still in the process of closing.
However, again I feel it's due to debugging a release built application.
I had a similar issue in the last couple of days. The reason this happened to me is because I was testing a Windows Service I created. When I forgot to stop the service, and tried to build, I got this error.
Follow the suggestions in the other posts. As well, you may want to download Process Explorer from Microsoft - It might give you additional insight and allow you to kill any linger process.
What version of Visual Studio? You tagged it as VS 2013, correct?
Did you look at the following threads at Microsoft? Many complaining about similar issue.
https://connect.microsoft.com/VisualStudio/feedback/details/533411
http://connect.microsoft.com/VisualStudio/feedback/details/811846/visual-sudio-cant-complie
http://connect.microsoft.com/VisualStudio/feedback/details/647826

VS 2008 suddenly can't start debugging session

I am having great problems running the application in the debugger from Visual Studio 2008.
When I'm using vshost.exe, it says:
And when vshost.exe is turned of, it simply states:
Interesting thing about it is that when i do use vshost, debugger is actually started and breakpoint is hit on the first line of the Main().
I tried:
rebuilding the project(s)
removing .ncb, .suo, .user for the projects
repairing Visual Studio 2008
changing the build architecture for the project
... no help there...
Any experience in (trouble)shooting that?
More info: some projects DO work, and one that I have to work on, does not.
I have some ideas such as:
trying to create NEW project, add thing by thing to it and see at what point it will start to miss behave
work it other way around, delete project by item by item to see when it will (if it will) be working OK again.
EDIT (for google, as I see that there are many similar questions on the web):
Errors:
Error while trying to run project: Unable to start debugging.
and
Error while trying to run project: Unable to start program '....\PlayKontrol.exe'
Try upgrading your Visual Studio to Service pack 1, if you haven't already.
Did you restarted your computer? You never know how windows will react to that :).
Also be sure there aren't any keys stuck, like the ctrl or windows key.
Note that the key does not have to be visually stuck, it can be stuck for visual studio and not for the explorer.
The most common source of sudden problems like this is corruption of one of the data files that vs uses to cache information between builds.
You've tried a clean build, but this won't delete everything. A real clean build is: quit vs, delete bin, obj, debug, release folders, delete all generated files in the root - primarily ncb. Do the same for any locally built libraries that you're project references.
The easiest way to do this is if you have the code in source control, as you can rename away your entire code folder and then force a get of all the source.
You often need to do all of these things in one hit to clear the problem.
Less frequently, a reinstall of vs will sort things out (although this sounds unlikely in your case if it is only one project that breaks)
Also think carefully about anything you might have installed just prior to it failing... And remember that some install effects may not occur until the next reboot so it could be days ago. A particular cause of this are automatic windows updates and trial versions of things like the vs 11 beta.
You might try running the application from outside of VS, but have a line of code that looks like this: Debugger.Launch(); where you want your first breakpoint.

Pressing F5 in Visual Studio 2010 Builds but does not Launch Application

I have a Click Once application (WPF) in C#. Initially when I would hit F5 to debug/launch the application it worked smoothly. Eventually, F5 only would build the solution and not launch the application (therefore I could not step through my code). For a short while I switched from Debug to Release mode and for some reason that allowed the application to launch after using F5 and I could step through my code again. But now that no longer works either. Long story short, I cannot get the application to run in a manner that allows me to step through the code. I can only do a Start without Debugging (Ctrl + F5). Obviously this doesn't do much for me other than tell me if the application works or not.
The thing that worked for me today was to open Task Manager and look for any debug programs that didn't terminate properly.
Task Manager > Processes > kill all programs "*.vshost.exe *32"
You probably have lost your start up project in the solution, or the start up project is messed up, and no correct "item" is defined for the startup.
Right click on one of your projects, and select : define as startup project.
Then retry that should do the trick. If not, check in that projects properties to see if a form or something is defined as the startup object for that project.
Edit : Obviously dont define a class library project as startup project, but choose your UI :).
I had this same issue today and came here looking for help. I tried all the suggestions here and nothing helped.
Seeing as my solution was a simple console application I recreated it from scratch. The new solution didn't exhibit the problems, so I started comparing the two.
I reset the solution and project files so that they were identical (apart from Project GUID, name and root namespace) but the first solution still didn't run.
I then tried deleting the suo files, and the bin and obj folders. Still the first solution wouldn't run.
Finally, I noticed the vshost.exe process was still running for the project. When I killed that and reloaded, it all started working correctly.
I just had this problem today. The solution turned out to be a slight twist on the issue with *.vshost.exe mentioned previously.
I could build the application just fine but msvs refused to launch it. I could manually launch the application and the time stamp on the file indicated that it was in fact a fresh build as well. *.vshost.exe wasn't showing up in the task manager, so I couldn't end the process as suggested.
When all else failed, I tried deleting the .exe's and found that *.vshost.exe would not delete because it was in use. The error message indicated that it was actually the steam client (third party software) that had somehow grabbed my *.vshost.exe file and was "using" it. Not sure how or why. At any rate, I completely shut down steam, then it let me delete *.vshost.exe. After that, building and running from msvc worked normally.
Had the same issue, eventually tried deleting all breakpoints and the debug started working again. Yet to figure out why, but at least it works.
As well as the ghost *.vshost.exe. It could also be that you have the same Solution/Project open in another version of VS. I had the same Solution open in both VS2010 and VS2015 and when running in VS2010 it compiled but failed to start. Closing the VS2015 Solution and it ran as expected.
After years of using VS 2008, I suddenly had the F5 problem not launching the application. There must be a dozen different suggestions out there - I tried a few. Someone suggested a virus. My Microsoft Security Essentials was not automatically updating (a common problem it seems), so I manually updated it. It found a virus, removed it, and the F5 problem went away !
Had this problem and tried to delete everything in bin/debug folder but could not delete vshost.exe file - kept requesting admin permission and then still could not remove it even though running from admin account. Restarted and file was gone and f5 worked again

Visual C# 2010 Express keeps File Handle after Debugging

After debug, in about 90% of the cases I can't rebuild my solution, because VS keeps the file handle of the old .exe (can't copy the new exe from obj\Debug to bin\Debug). I know that it's VS's file handle for sure, since I checked it with the Unlocker Assistent. Also, I tried the workaround with calling the default namespace the same es the executable, but no luck. Any ideas?
PS: Running it on Windows XP.
Seems to be a bug in VS since 2005. A google search will show MANY posts about this problem that Microsoft has yet to address. It hits me every so often as well when the IDE won't let go of a dll. Unfortunately a restart of VS is required :(

Categories

Resources