views:

104

answers:

1

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

A: 

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);

Max Yaffe