简体   繁体   English

当dll被调用时,断点永远不会被击中

[英]Breakpoint never hit when dll would be called

I have added a managed c++ dll to my c#.net project (using "add resource"); 我在我的c#.net项目中添加了一个托管的c ++ dll(使用“add resource”); it finds the class I'm trying to instantiate just fine, no compiler errors. 它找到我试图实例化的类,没有编译器错误。 But somehow, fields I know I instantiated are getting null reference exceptions. 但不知何故,我知道我实例化的字段是获取空引用异常。 So I put in a breakpoint at the top of the method that sets the field... and it's never hit. 所以我在设置字段的方法的顶部放置一个断点......它永远不会被击中。 If I comment out the line using the class from the .dll, it hits the breakpoint. 如果我使用.dll中的类注释掉该行,它会触及断点。 Uncomment that and the method never executes despite being called. 取消注释,尽管被调用,该方法永远不会执行。 What's happening here? 这里发生了什么事?

The dll is ManagedSpyLib, the class is ControlProxy , if that helps any. dll是ManagedSpyLib,类是ControlProxy ,如果有帮助的话。 The call is inside the DoWork method of a backgroundworker which is most definitely getting started asynchronously -- could that entire thread be crashing silently without even alerting the debugger? 调用是在后台工作者的DoWork方法中进行的,这种方法绝对是异步启动的 - 整个线程是否可以在没有警报调试器的情况下静默崩溃? How can I debug this? 我该怎么调试呢?

ETA: I couldn't find anything about the dll in the output window or the Modules window. ETA:我在输出窗口或模块窗口中找不到关于dll的任何信息。 Some googling found a fix: change the target to the .net 3.5 framework. 一些谷歌搜索发现了一个修复:将目标更改为.net 3.5框架。 But I'm no closer to understanding WTF is going on than before -- my code works, but now I have no idea why, which is even more puzzling. 但是我对WTF的理解还没有比以前更接近 - 我的代码有效,但现在我不知道为什么,这更令人费解。 Can someone explain this phenomenon? 有人可以解释这种现象吗?

Generic steps for debugging unknown errors/failure to stop at breakpoints: 调试未知错误/在断点处停止失败的一般步骤:

Make sure you have PDBs loaded for DLL in question (Debug->Window->Modules). 确保为有问题的DLL加载了PDB(Debug-> Window-> Modules)。 Make sure sources match the version you are using. 确保源与您使用的版本匹配。

Check if there are any suspicious traces (especially about exceptions) in Output window while you are debugging. 在调试时,检查“输出”窗口中是否存在任何可疑跟踪(尤其是关于异常)。

Consider breaking on all exceptions (Debug->Exceptions -> "When thrown" for CLR exceptions). 考虑打破所有异常(对于CLR异常,调试 - >异常 - >“抛出时”)。 May need to disable "my code only" (Tools->Options->Debug->My code only) to break on all exceptions. 可能需要禁用“我的代码”(工具 - >选项 - >调试 - >仅我的代码)以中断所有异常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IEqualityComparer 上的 Equals 断点<customclass>从未被击中</customclass> - Breakpoint in Equals implimentation on IEqualityComparer<CustomClass> is never hit 为什么在使用AutoMock.GetLoose()时断点永远不会被命中? - Why does my breakpoint never get hit, when using AutoMock.GetLoose()? 由调试器引起的命中断点 - Hit Breakpoint When Caused by the Debugger 遇到断点时执行代码? - Execute code when breakpoint is hit? 断点当前不会被命中。 没有为该文档加载任何符号。 删除dll时 - The breakpoint will not currently be hit. No symbols have been loaded for this document. when debussing dll 无法调用函数,未命中断点,-无法从 mscorlib 加载程序集 - Function cannot be called, no breakpoint hit, - could not load assembly from mscorlib 实现ISerializable时,永远不会遇到GetObjectData()方法 - GetObjectData() method is never hit when implementing ISerializable 有 CR:CrystalReportViewer 时 C# 断点不会命中 - C# Breakpoint does not hit when there is CR:CrystalReportViewer 当字符串变量包含char“ $”时,我的断点没有被击中 - My breakpoint is not being hit when a string variable contain the char “$” 断点当前不会被命中,cshtml - The breakpoint will not currently be hit, cshtml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM