26

When I try to build my project, it returns the following error:

Error 1 Unexpected error creating debug information file 'D:\Documents\Lance\Documents\School\Capstone\GG\GG\obj\Debug\GG.PDB' -- '' GG

I've recently had the misfortune of having my PC restart on me, due to sudden power supply problems (maybe). This is while the project was building, before this problem started.

When the PC came back online I've noticed that the changes I've made to the program prior to the sudden power down was not saved. And, it won't build anymore.

CharithJ
  • 46,289
  • 20
  • 116
  • 131
zack_falcon
  • 4,186
  • 20
  • 62
  • 108

10 Answers10

41

This worked for me:

  1. Shut down VS.NET
  2. Browse to the project in Windows Explorer
  3. Delete the /obj/ folder.
  4. Delete the project outputs (.dll and .pdb) from /bin (not sure if this step is necessary)
  5. Can't hurt but might help: delete the project outputs from any other project /bin folders in the solution that is having issues (wasn't necessary for me)
  6. Restart VS.NET
  7. Rebuild

http://weblogs.asp.net/ssmith/archive/2003/08/12/23755.aspx

Peladao
  • 4,036
  • 1
  • 23
  • 43
Winter
  • 411
  • 1
  • 4
  • 3
  • worked for me :) i the power went off and i that error happened, i deleted obj folder, then rebuild it worked cool. – Bassem Wissa Jun 25 '13 at 13:38
  • This worked, though I had to do an `iisreset` before I could do step 3, as `w3wp.exe` was holding onto the .pdb file in /obj/ – Nick Orlando Jan 21 '14 at 19:59
  • it worked for me first time.. but again it falls. I had to rename my assembly name to make it work. No need to restart your VS. – KMX Mar 06 '16 at 08:39
22

As requested, my comment as an answer:


Try cleaning the solution (under the Build menu in VS).

Since the build was interrupted half-way through by your power failure, the file isn't locked -- the build system is probably just in an inconsistent state (which a Clean Solution should fix).

Cameron
  • 96,106
  • 25
  • 196
  • 225
10

This happens once in a while in my environment and the problem probably has to do with the PDB file being locked (i.e., I'm guessing the last part of the error message is missing in your post). This is how it looks on my machine:

Unexpected error creating debug information file 'c:\dir\obj\file.PDB' -- 'c:\dir\obj\file.PDB: The process cannot access the file because it is being used by another process.'

In my case, cleaning the solution does not solve the problem and restarting is an overkill, so I usually just copy the full name of the pdb file (from the error) and execute this on the command line:

ren c:\dir\obj\file.PDB *.old
steinar
  • 9,383
  • 1
  • 23
  • 37
  • Yes. Obviously the file is not important. Renaming the file worked like a charm :) – henrik Jan 22 '14 at 11:14
  • 1
    Well, I would say that the file is important, i.e. if you want to debug. But it will be recreated on the next build. – steinar Jan 23 '14 at 08:18
7

This worked for me: Close Visual studio and open visual studio using Run as Administrator and problem was solved.

pooja
  • 71
  • 1
  • 3
2

Not need to restart or delete the file. Just rename the file and that is enough. If you try to delete the file it will give an error. Better just rename it & it will work. :)

Gaurravs
  • 639
  • 1
  • 15
  • 30
1

If you are having this problem with a web application, this can happen in the unusual situation that you have used DebugDiag and created a rule that listens on your project's app pool. Deleting the rule prevented this problem from recurring.

This might happen, for example, if you followed these instructions for diagnosing a stack overflow exception in IIS.

Community
  • 1
  • 1
Kirk Woll
  • 76,112
  • 22
  • 180
  • 195
1

If you are working on VM with two user, make sure the other user has not attached all the process while debugging.

0

Cons of restarting VS:

  • Clipboard will be lost
  • Redo/undo will be lost
  • Files open will be lost
  • You will loose the tempo

Solution: Give your Assembly a new name. No cons. Except you will have to rename your assembly back to its original name when you are ready for final deployment. And I think anyone can find how to make it work for the last time :)

KMX
  • 2,631
  • 1
  • 23
  • 28
0

Sometimes all the files from \bin folder are used by a running process, i.e. web site on IIS or windows service run automatically after build. In such cases turning off the service or stoping IIS app pool for specific site should also help (like in my case)

Marek
  • 1,688
  • 1
  • 29
  • 47
0

Sometimes I run into this problem, when compiling the same project for (very) different targets:

  • VS2008 and net35
  • VS2017 and net462
  • dotnet core 2.0

My guess is, that either bin and/Or obj directory are used by the compiler, but the outputs are not compatible (of course). Solution clean from VS indeed helps.

Often we specify different dll names for the output (e.g. mylib.dll, mylib35.dll) and the issue never happened on those projects.

Patrick Stalph
  • 792
  • 1
  • 9
  • 19