Mixed mode assembly not loading symbol for native

2019-02-22 05:50发布

问题:

I am working with mixed mode assemblies in C++/CLI. All managed mode assembled pdb's get loaded when successfully in mixed mode assembly, but native dll's and pdb's are not getting loaded even though the information of native pdb's is shown in the Modules pane (i.e. in VS Debug->Windows->Modules).

I am using native dll and calling its exported function in mixed assembly in C++/CLI code. Here, functions get called successfully, but native pdb symbols are not loading and all breakpoints in the native code are shown as hollow circle and tool tips says there are no symbols loaded for this.

I have done everything, pdb placed in current directory to where the managed process is launched; deleted all obj and debug folders and recompiled every project at the same time; I even used the ChkMatch utility which shows that the symbols in the Exe and corresponding pdb match.

Is there any way to enable breakpoints of native code while calling from managed (C++/LCI Mixed mode) code?

Regards,

Usman

回答1:

Mixed-mode debugging can be hit and miss, mostly miss. First check that you've actually have mixed-mode debugging enabled. From a C# project, it is Project + Properties, Debug, Enabled unmanaged code debugging check box. Next, mixed-mode debugging is not enabled for 64-bit processes. If you run on a 64-bit operating system, make sure you force the .exe to run in 32-bit mode. Project + Properties, Build tab, Platform Target = x86.

Next verify where the debugger looked for the .pdb files. From the Debug + Windows + Modules window, right-click the DLL and select "Symbol load information". Final gasp is to use __debugbreak() in the unmanaged code.