0

I search a way to locate UnhandledException in a native c++ desktop application. The error occurs in a .net assembly that is called by in process com interop. Problems are I do not know witch assembly causes the UnhandledException and I can not reproduce on my developer machine, so I can not simply use the debugger.

I try with AppDomain.CurrentDomain.UnhandledException but I think each com call get it's own AppDomain. Whatever it does not work, app is still crashing and event is not triggered.

Also I try to use stackify prefix, but may app is not an webservice and not an windows service, so this does not work.

Event logs are written but do not point to the error.

Any idea how I could identify the assembly causing the problem?

-- Edit -- Not all assemblies used via com interop are my own, so it is not that easy to add code to all of them.

Erros in event log is: Source: .Net Framework ID: 1026 Message: The process was terminated on a unhandeled exception. Errorcode c0000005

Daniel W.
  • 938
  • 8
  • 21
  • 1
    You will never get AppDomain.UnhandledException because exceptions are never unhandled in [ComVisible] .NET code. They are always caught by the CCW and turned into an HRESULT error code, passed back to the code that called the method. Fwiw, that is the basic reason why every .NET exception class has a HResult property, that's what the C++ code sees. So this problem is located in the C++ code, it doesn't do a good-enough job to help you diagnose the error. Maybe you used #import and forgot to catch the `_com_error` exception, something like that. Not something to leave us guessing at. – Hans Passant Dec 14 '18 at 13:26
  • what about AppDomain.FirstChanceException is it triggert for all com assemblies or have all Calls it's own AppDomain? – Daniel W. Dec 14 '18 at 13:54
  • Okayish for logging, you need a God class to subscribe it. But that doesn't stop the C++ code from failing. – Hans Passant Dec 14 '18 at 14:01

0 Answers0