39

For some reason this error started popping up today on one of my projects.

Error 1 Unable to write to output file 'C:\MyProject\Release\MyProject.pdb': Unspecified error

If I go into advanced compile options and change it to not generate and debug info, my project compiles fine.

I have tried setting the permissions on the Release folder to full for everyone, so I would assume it's not a permissions issue. Also, I don't see anything in my log files that would provide me with more information about the issue.

Does anyone know why this error would just start showing up or a way to fix it?

Thanks.


Update: I have rebooted my machine, restarted VS several times and have even completely deleted the existing OBJ file where the issue is happening. It's still giving me the same error.

This is a simple one project solution that was working fine just last week. It appears to be an issue with VS trying to build the PDB file because I can delete them out of the Release and Debug folders without issue. When I try rebuilding them VS will start creating the file (about 1.4MB is size) but I still get the error.

SamB
  • 9,039
  • 5
  • 49
  • 56
Ryan Smith
  • 8,344
  • 22
  • 76
  • 103

16 Answers16

56

After banging my head on the wall for a while on this one and digging through source control to try to get back to a working copy, it turned out that the PDB file wasn't the issue at all. Someone had deleted a source file which was causing VS to choke when I tried to find that file to create the debug information.

So if anyone comes across this error and can't figure it out, make sure that you aren't missing a source file somewhere.

It would have been very helpful if VS would have told me that file is missing rather than just telling me it had an unspecified error creating the PDB file.

Thanks.

Ryan Smith
  • 8,344
  • 22
  • 76
  • 103
  • I came hear looking for a solution to the same problem. I had converted a "Web Site" to a "Web Project". This changes the "App_Code" folder to "Old_App_Code". Somehow, VS expected to find the files in both folders simultaneously. I didn't know MS was into quantum mechanics. I saw the missing files in "App_Code" with the yellow warning icon. When I deleted "App_Code" from the project, VS found my files in "Old_App_Code" and it worked just fine! – Vivian River Mar 17 '10 at 13:57
  • 1
    thanks, finally able to resolve this. wasted too much time chasing ghosts! – TheZenker Mar 23 '10 at 20:25
  • 7
    Worst. Error. Message. Ever. Sadly, this was the solution to my coworker's problem as well. – ulty4life Jan 07 '11 at 17:31
  • Traced to missing copied files, e.g. "Copy of ..." which weren't in the VS solution explorer. Added the files back and it worked. – GlennG Oct 26 '11 at 10:50
  • If you're using the SVN plugin for Visual Studio, look for these icons for the missing files. The vbproj or csproj file have these files referenced but the files are not in SVN, and you probably did an update. Go into SVN and blame the person who committed the vbproj or csproj file for not adding/committing the new files. :-) http://screencast.com/t/oawcLCyrY3vK .. to fix, just delete the files from Visual Studio (you're just deleting the reference in the vbproj/csproj file) or add some dummy files until that person commits them to SVN. – JustBeingHelpful Nov 14 '11 at 17:32
  • 1
    After applying this solution I finally got my solution to build. Then it was on to find out who the culprit was ... yeah it was me! FML – Shai Cohen Mar 14 '12 at 00:08
35

Here is a MUCH better way to fix this issue.

Basically close your solution and re-open it without compiling. Check the Error List and it will show you which files are missing.

Colin Pear
  • 3,028
  • 1
  • 29
  • 33
  • 3
    Thank you. I don't understand why this isn't the "checked" answer. – Matt Smith Sep 20 '13 at 20:10
  • It appears to be a matter of timing of why this isn't the accepted solution. I'm so glad this reply was here, I up-voted because it gave me a quick way to find out which files were missing. – vbigham Sep 20 '14 at 22:24
  • This is the good answer, in my opinion. The previous one is incomplete. It works for me, thanks. Up-vote. – Matte Sep 16 '15 at 08:57
2

This worked for me where the other answer's here failed:

Unable to write to output file [FileName] .pdb: Unspecified error Visual Studio

Markive
  • 2,350
  • 2
  • 23
  • 26
1

I was receiving the same error and it ended up being a web reference that needed to be updated. After updating all the web references the issue persisted. Finally I added the same web reference as the same url and name and the add web reference told me that there was a reference by the same name and provided an option to update it with the latest information. This finally worked and the project is running again.

AACinc
  • 11
  • 1
1

I wanted to add on top of the typical Turn it off and on again with the reason why that's helpful.

Visual studio can get wrapped around the axle when building a project so that it can't figure out why it's missing a particular dependency, it just knows that it can't build the project.

Here's an undescriptive error message after a failed rebuild:

Unhelpful Error

The solution is to:

  1. Close Visual Studio
  2. Open Visual Studio
  3. Do Not Compile - Look at the error list for a new descriptive error:

Helpful Error

A lot of the existing instructions are missing the third step, so I thought this might be helpful.

KyleMit
  • 30,350
  • 66
  • 462
  • 664
1

Check for missing files which will be shown in visual studio with exclamatory icon and those files may not exist in project source folder. if you don't want those files delete them in visual studio else add those files in source folder. clean or refresh..

ramp
  • 11
  • 1
1

Perhaps something else has the file open, like an editor or another copy of Visual Studio?

Try shutting down and restarting VS, or even rebooting your machine to see if that resolves the problem.

Tim Sullivan
  • 16,808
  • 11
  • 74
  • 120
1

In the worst case try to restart Visual Studio. Another good tool for you to try is Process Explorer from SysInternals that allows you to see who is keeping handle on your PDB file. This way you know exactly what to kill/restart to get access to the file.

David Pokluda
  • 10,693
  • 5
  • 28
  • 26
1

If you work on solution with more than one projects inside, there is possibility of wrong compile order.

Avram
  • 4,267
  • 33
  • 40
0

I was getting same error. Turned out that the 'Service Reference' folder was out of date. I deleted and added service reference again and it started working.

Brian Webster
  • 30,033
  • 48
  • 152
  • 225
0

This same error happened to me but it had a different cause. Someone had deleted a file for a project but didn't update the project file; therefore the project was looking for the file. The file had a yellow caution icon displaying over it. When I excluded the file from the project the issue was fixed.

Jeremy Ray Brown
  • 1,499
  • 19
  • 23
0

I'm on VS2005 and encountered this error when I opened a web project as a "Solution"--opened the .sln file--and hit build/rebuild. Once I closed the Solution and re-opened it as a "Project"--opened the .vbproj file--I got the specific missing source code errors when I compiled/recompiled. I made sure all the files were present and voila, it completed the build successfully!

danlee
  • 733
  • 8
  • 13
0

I had this problem in a VS2010 solution and I tried all of the accepted answers above but still couldn't figure out why the compiler can't find the (Test.vb) file. As some of the answers has already mentioned, .pdb file is not the actual error.

The error is the one appears in the error list after re-opening the solution without building it, which is, Unable to open module 'C:\Test\Test.vb'. However, re-opening the solution did not work for me. The error was suggesting that 'Test.vb' is missing even though 'Test.Vb' file EXISTS in my local copy. So why it can't find it?

The solution I found for this, is:

  1. Close the solution, close VS2010 and re-open the solution in VS2015. VS2013 might also work but I have not tried it.
  2. I built the solution in VS2015 which of course failed but the error this time (particularly in Output window, where it shows the build lines, including the errors occurred during the compile) was showing the full PATH of the 'Test.vb' file that the compiler was trying to locate. The path was 'C:\Test\..\..\Test.vb' suggesting that, in building 'Test.vbproj' project, the compiler started its build in 'C\Test' folder and then appended the location of the .vb file, defined in the .sln file which is '..\..\Test.vb' to read 'Test.vb' file and build the project. Only it couldn't navigate to 'C:\Test\..\..\Test.vb' folder, where 'Test.vb' is.

By correcting the location of 'Test.vb' in .sln file, it built fine.

SouthSun
  • 79
  • 1
  • 3
0

The reason is almost certainly that another process is hanging onto a handle to that file which prevents it from being overwritten. VS is unfortunately often the culprit. If this is the case, restarting VS will fix the problem.

JaredPar
  • 733,204
  • 149
  • 1,241
  • 1,454
0

Visual Studio sometimes gets a bit "confused" about files being locked, especially if during a previous debugging run the application being debugged crashed unexpectedly, Visual Studio crashed unexpectedly, or even sometimes if you simply stop debugging.

Generally, the solution is to close and reopen Visual Studio.

Scott Dorman
  • 42,236
  • 12
  • 79
  • 110
0

Yes - definitely check for files that didn't get pulled down from VSS, if that's where you got your project from. Just look for the files with exclamation marks. Once all files in the project are where they should be locally, PDB gets generated w/o problems.