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

后端 未结 3 475
遇见更好的自我
遇见更好的自我 2021-01-03 02:39

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#. Th

相关标签:
3条回答
  • 2021-01-03 03:13

    Here is my fifty cent. In my case it appeared that the pdb files of my c++/cli projects were not updated anymore, while the pdb files of my c# projects were. This probably rendered them invalid and made the debugger fail to load them.

    I remembered to have moved the source base of my project. After a little bit of grepping it occurred to me that some absolute path issue might be the problem. Running a git clean -dfx solved the problem for me.

    0 讨论(0)
  • 2021-01-03 03:16

    I have a Windows Service in C# with a C++ DLL. The problem I saw was what Max noted:

    • The DLL worked, but never showed up in the Modules window.

    I have done a lot of searching and this is a nice list which matches with information from many other sources.

    To make ikh's note explicit:

    • "Auto" did not work for me, but explicitly setting "Native" and "Managed" code in the Attach dialog worked.
    0 讨论(0)
  • 2021-01-03 03:26

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

    0 讨论(0)
提交回复
热议问题