英文:
Visual Studio debug C code in the .dll library from C#. How to load symbols on program load
问题
我有一个.dll
库,我在C#代码中使用它。我已成功配置了VS以调试.dll
中的C代码。但是有一个小问题。符号文件在第一次调用.dll
库中的代码时加载。即使我想进入第一个函数,这在这个时候是不可能的,因为此时没有符号。第二次函数调用可以正确调试。如何强制VS调试器在应用程序启动时加载符号?
另外,我有一个变通方法 - 我在一个虚拟函数上中断C#代码 - 尝试进入(虽然不会发生,但会强制加载符号)。
英文:
I have a .dll
library which I use in C# code. I have successfully configured VS to debug the C code in the .dll
. But there is a small problem. The symbol file is loaded on the first call to the code from the .dll
library. Even if I want to step into the first function it does not happen as it has no symbols at this point of time. The second function call can be debugged correctly. How can I force the VS debugger to load symbols on the application startup?
PS I have a workaround - dummy function I break C# code on - step into (it does not happen, but forces the symbols load).
答案1
得分: 2
答案是我们无法这样做。
这个dll文件是动态加载的。因此,只有在调用C函数时才会加载dll的pdb。
在设置断点后,在C#项目的属性设置中启用“启用本机代码调试”,当触发断点时,符号将被加载。
英文:
> Visual Studio debug C code in the .dll library from C#. How to load
> symbols on program load
The answer is we can't.
The dll file is dynamic load. So the pdb of dll will only be loaded when the c function be called.
After setting the breakpoints, turn on the "Enable native code debugging" on C# Project side property settings, the symbol will be load when hitting the breakpoints.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论