“The breakpoint will not currently be hit” error while debugging a mixed mode application (c# and unmanaged c++)

落爺英雄遲暮 提交于 2021-02-08 10:44:53

问题


While debugging a mixed mode application in VS2010, the breakpoint set on a line of code contained in an unmanaged c++ dll source file (called from a managed c# wrapper class) shows the infamous "The breakpoint will not currently be hit. No symbols have been loaded for this document" info message when hovering the mouse over the breakpoint on the line in question. The breakpoint itself is a red circle with a yellow info triangle instead of the usual solid red orb. Of course, the breakpoint isn't hit when the debugger is executed. Most answers I've found for this warning indicate the breakpoint hasn't been set properly, or that the expected dll is not being loaded, or that the associated pdb file is not located in the correct location, etc. etc. This is not the problem. The application does load and execute the referenced dll correctly. I've verified that the correct pdb file, with the same file date as its dll, is located in the executable's working directory along with the target dll itself. The debugger simply doesn't load the symbols for the dll, and the dll doesn't show in the Modules list.

None of the solutions I've found online work for this problem. The dll doesn't show in the modules list available from 'Debug->Windows->Modules' menu selection... even though it is, in fact, loaded. Breakpoints set in the wrapper class work correctly.

Deleting the bin and obj directories, cleaning and rebuilding the solution also doesn't help.


回答1:


The solution to this problem was to set the "Enable unmanaged code debugging" flag located in the Debug tab of the application's properties page




回答2:


You aren't hitting the code, and aren't having the dll show up in your modules list, because it's not being loaded by the program. So whatever your C# wrapper is calling, it's not that - or maybe that's not getting called correctly.




回答3:


It's a little unclear as to what your error is, but if you are getting the message that says "the breakpoint will not currently be hit", it means exactly what it says - you are not hitting a breakpoint you set. Try looking back in you program and see where the breakpoints are (they should be red dots in the margin), then see if you are actually getting to them



来源:https://stackoverflow.com/questions/12465468/the-breakpoint-will-not-currently-be-hit-error-while-debugging-a-mixed-mode-ap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!