Reputation: 758
I have added a managed c++ dll to my c#.net project (using "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. 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. 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? How can I debug this?
ETA: I couldn't find anything about the dll in the output window or the Modules window. Some googling found a fix: change the target to the .net 3.5 framework. 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. Can someone explain this phenomenon?
Upvotes: 1
Views: 661
Reputation: 100575
Generic steps for debugging unknown errors/failure to stop at breakpoints:
Make sure you have PDBs loaded for DLL in question (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). May need to disable "my code only" (Tools->Options->Debug->My code only) to break on all exceptions.
Upvotes: 3