Symbol file not loading for debugging custom project in Visual Studio 2012

C#.NetVisual StudioVisual Studio-2012Msbuild

C# Problem Overview


I have a large solution in Visual Studio 2012 which consists of executables and class library projects. When debugging the application the breakpoints in one particular class library project are not being hit.

I looked at the Debug> Windows> Modules window to check the status of the symbols for that project and it says "Cannot find or open the PDB file".
It also says "No" under the "User Code" column.
I notice that there are a few other of the custom projects in the solution that are showing "No" in that column and their symbols are also failing to load. Anything with a "Yes" under "User code" seems to have had it's pdb loaded no problem. But I'm not sure if this is relevant.

I have used dumpbin /headers on the dll and the path for the pdb file is present and correct.

The module is definitely not in the exclude list for the symbol loading.

I have also tried right clicking on the entry in the modules window, selecting "Load symbols" and navigating to the path given in the dll header. When I select the pdb it says "A matching symbol file was not found in this folder".

I get this after I have deleted these folders and files, cleaned the solution, closed it and rebuilt the whole thing. The pdb was definitely built at the same time as the dll in question.

So clearly the problem is the "cannot open the pdb" portion of the error message.

I have tried this on 2 computers and both are exhibiting the same behaviour.

Can anyone offer any suggestions on where to go from here, and perhaps why on earth the built pdb corresponding to the dll won't load for it?

C# Solutions


Solution 1 - C#

I tried a few tools to check if the pdb and the dll actually matched, and using chkmatch I could see that the GUIDs in the dll being run and the pdb in the obj folder didn't match.

So it turns out that although the dll and pdb in the project's obj folder are a match, the dll that was actually getting copied to the application's destination folder by a post-build event was the old dll from the previous build.

The post-build event was running before that particular project had built, or at least finished building, and was copying in the existing dll from the bin which was subsequently overwritten by the continuing build.

I have resolved the problem by editing the project dependencies for the solution and ensuring that the project with the post-build event is dependent on the project that wasn't loading, and now the pdb loads during debug.

Solution 2 - C#

I simply deleted bin and obj folder from the startup project folder and rebuild the solution.

Solution 3 - C#

For me I just deleted the project from IIS and created it again and it works fine

Solution 4 - C#

For me it helped to use chkmatch tool and then just close and open visual studio, make clean and rebuild. Now my pdb gets also loaded. You can make sure it does, as Nanhydrin pointed out, from Debug -> Windows -> Modules - this view is only accessible during debugging.

Solution 5 - C#

I found that the project I was receiving the message about, was being optimized when built.

I went into the projects properties, Compile Tab, Advanced Compile Options... and unchecked the Enable Optimizations checkbox

Deselect Enable Optimizations

Solution 6 - C#

In my case older version of referenced dll was in my GAC. Cleared it out, and it worked.

Solution 7 - C#

In my case there was a check mark on Enable Just My Code in Tools>>Options>>Debugging>>General.

I unchecked it and it worked.

Example Image

Solution 8 - C#

Reminder: Put the project into "Debug" configuration... for those like me who forget and feel silly.

Solution 9 - C#

I just had this issue and thought I would put my fix here, as it my help others (maybe even myself again?!) in the future...

Make sure that when you are attaching to the process on the remote server, that the "Attach to" is set to

> Automatically determine the type of code to debug

To do this, When the server qualifier has been provided and a list of processes is visible, click the "Select" button next to the "Attach to" input.

[![Image 1][1]][1] [1]: http://i.stack.imgur.com/aQaCX.jpg Then, select "Automatically determine the type of code to debug" and OK out of the screen, then attach.

[![Image 2][2]][2] [2]: http://i.stack.imgur.com/pBZ1q.jpg
This fixed the issue for me, at least.

Solution 10 - C#

Deleted the project from solution and added it again to the solution worked for me. :)

Solution 11 - C#

Bit late to the party here - just in case this is helpful.

We have a couple of separate websites (in different solutions in Visual Studio). On initial load of one of the sites, we were making a call to the other site which would return an image.

Both of these sites referenced a common DLL, but while working on one site, had not realised that the other site had been left in a 'Release' build - after the site loaded, the offending DLL was rebuilt, but without symbols.

Kudos to Nanhydrin for both mentioning the modules debug window (very helpful) and for putting me on the right track with the post build event.

Solution 12 - C#

Answer from another thread that worked for me: https://stackoverflow.com/a/28476665/5969306

  • In Visual Studio: Project Properties -> Build -> Advanced button -> Debug info drop-down and make sure the value is not “none”.

Solution 13 - C#

I had a line like this in my debug window:

> Symbols for the module 'MyModule.dll' were not loaded.

I removed the 'Optimize code' option in Project properties -> Build. And the error disappeared.

Solution 14 - C#

This issue may be due to wrong reference of dlls used in project.

Delete obj and bin folders in current project and build project again.

Solution 15 - C#

Check for permission to ASP.NET Temporary folder:

"c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files"

User of application pool has to have the rights to subfolder with ASP.NET files, something like:

root\60039743\c28e12ee

Solution 16 - C#

  1. Check options from this answer: https://stackoverflow.com/a/38377530/6911991
  2. Click Advanced and check that Debugging Information is set to FULL
    Advanced tab screenshot
  3. Check Run Configuration in all projects in the solution

Solution 17 - C#

I had this issue , tried all the other solutions (it took 2 days !! I'm crying... !TWO DAYS!) But finally I realized that my file was registered in GAC, I removed it and the problem was resolved.

At the command prompt, type the following command:

gacutil –u <assembly name>

How to: Remove an Assembly from the Global Assembly Cache

Solution 18 - C#

Please check the dependency of your dll, if you added to the solution, this can cause failure in loading symbols.

Solution 19 - C#

I resolved this issue by disabling 'Use Managed Compatibility Mode' in the Debug->Options menu:

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNanhydrinView Question on Stackoverflow
Solution 1 - C#NanhydrinView Answer on Stackoverflow
Solution 2 - C#MacGyverView Answer on Stackoverflow
Solution 3 - C#Mohamed BadrView Answer on Stackoverflow
Solution 4 - C#PompairView Answer on Stackoverflow
Solution 5 - C#chris31389View Answer on Stackoverflow
Solution 6 - C#Jehonathan ThomasView Answer on Stackoverflow
Solution 7 - C#Dominic LegendreView Answer on Stackoverflow
Solution 8 - C#SimpsOffView Answer on Stackoverflow
Solution 9 - C#dalemacView Answer on Stackoverflow
Solution 10 - C#Md Hasan IbrahimView Answer on Stackoverflow
Solution 11 - C#PaddyView Answer on Stackoverflow
Solution 12 - C#Boyan PView Answer on Stackoverflow
Solution 13 - C#RahbekView Answer on Stackoverflow
Solution 14 - C#Hassan NazeerView Answer on Stackoverflow
Solution 15 - C#InerrenView Answer on Stackoverflow
Solution 16 - C#Aleh BaslakView Answer on Stackoverflow
Solution 17 - C#MariaView Answer on Stackoverflow
Solution 18 - C#Ajith S JView Answer on Stackoverflow
Solution 19 - C#Philip RaathView Answer on Stackoverflow