Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Symbols loaded in mixed C# C(win32) project using VS2010

My project has several new C# modules and one C module (not C++) compiled using win32 system calls. I'm using the PInvoke interop layer to call the C code from the C#. The C function is getting called.

All modules are writing to a single bin directory and all write pdb files.

On running, and then stopping at a breakpoint right before a call into the C.dll, I see the breakpoints in the C module are disabled. Looking at the Debug|Windows|Modules list I don't see the C.dll module loaded even after the call has been executed.

One more factoid: in Solution|Properties|Configuration Properties|Configuration is shows the C# modules using Platform = "Any CPU" and the C module using "Win32"

Why isn't the module loaded and why aren't its symbols loading?

Thanks, Max

like image 597
Max Yaffe Avatar asked Aug 20 '10 21:08

Max Yaffe


People also ask

How do I fix No symbols have been loaded for this document?

"No Symbols have been loaded for this document"Go to the Modules window (Debug > Windows > Modules) and check whether your module is loaded. If your module is loaded, check the Symbol Status column to see whether symbols have been loaded. If symbols aren't loaded, check the symbol status to diagnose the issue.

How do you fix the breakpoint will not currently be hit no symbols loaded?

Start debugging, as soon as you've arrived at a breakpoint or used Debug > Break All , use Debug > Windows > Modules . You'll see a list of all the assemblies that are loaded into the process. Locate the one you want to get debug info for. Right-click it and select Symbol Load Information.

How do I see loaded symbols in Visual Studio?

In Visual Studio, open Tools > Options > Debugging > Symbols (or Debug > Options > Symbols).

How do I add symbols to remote debugging?

Go to Tools > Options > debugging > Symbols. Add a new Symbol file location for your build server. Make it point to the bin folder of the project you want to debug.


1 Answers

I've consolidated answers from several sources.

  • Are you running the debug configuration?
    In the Solution check: SolnExplorer|Solution|Properties|ConfigurationProperties| Configuration = Debug
    and: SolnExplorer|Solution|Properties|ConfigurationProperties| Configuration|ProjectConfig[]=Debug -->Note:Although breakpoints will work with release configuration, sometimes the lines may be optimized out or rearranged.

  • Are you generating debug information? In C# projects: SolnExplorer|Project|Properties|ConfigurationProperties|Linker|Debugging|Generate Debug Info=YES
    In C++ projects: SolnExplorer|Project|Properties|ConfigurationProperties|C/C++|Debug Information Format = Program Database(/Zi)
    -->Note: It pays to check the command line arguments.

  • Is everything is being rebuilt? If the PDB is out of sync, the debugger may not be able to load symbols:
    In Solution: SolnExplorer|Solution|Properties|Configuration Properties|Build=TRUE(Checked) for all projects.

  • Can you debug unmanaged code?
    In C# projects: SolnExplorer|Project|Properties|Debug|Enable unmanaged code debugging = TRUE(Checked)
    In C/C++ projects: SolnExplorer|Properties|Configuration Properties|Debugging|Debugger Type = Mixed

  • Are files being put where you think they are? I use a single bin\debug directory for collecting all project DLL's and PDB's.
    In the C# projects: SolnExplorer|Project|Properties|Build|Output Path = ..\bin\debug
    In C/C++ projects: SolnExplorer|Project|Properties|ConfigProp|Linker|OutputFile = ..\bin\debug\$(TargetName)$(TargetExt)

  • Are old files getting in the way? Check the timestamps on all the output files in the bin directory. Make sure they are as of the last rebuild.
    Some people advise blowing away all the bin and obj directories. This may be worthwhile just to see that old files aren't laying about. Checking the time and date stamps should do just as well.

  • Has the DLL been loaded? If the Breakpoints are disabled, it may be because the DLL has not been loaded yet. Check Menu|Debug|Windows|Modules.
    Look for the dlls in the module name.
    In the same Modules window make sure files are loading from the correct path.
    If an assembly is shared among several programs, it can be loaded from the GAC.
    -->Note: You can preload the C/C++ DLL before it is required. Use: IntPtr lpDLL = LoadLibrary(myLibraryName);

like image 157
Max Yaffe Avatar answered Sep 21 '22 20:09

Max Yaffe