0

I registered vectored exception handler. Using this article I manage to get the object's name from EXCEPTION_POINTERS structure pExceptionInfo:

char* objectName = (char*)(((DWORD*****)pExceptionInfo->ExceptionRecord->ExceptionInformation[2])[3][1][1]+2)

The object's name that I get is .PAVEEFileLoadException@@. So, as I understand it failed to load some kind of file. Is there any way to get the name of the file from EXCEPTION_RECORD or any other structure?

theateist
  • 13,879
  • 17
  • 69
  • 109
  • 1
    EEFileLoadException is an unmanaged exception that kicks off the .NET FileLoadException, a managed exception. No, there's is no known way to recover the info for that one without a debugger. Use a managed debugger of the DebugDiag utility or use the AppDomain.UnhandledException event. – Hans Passant Sep 08 '13 at 10:32
  • But how .NET FileLoadException will have an information of what file could not be loaded? I thought it gets it from EXCEPTION_RECORD, doesn't it? – theateist Sep 08 '13 at 11:05
  • No, it gets it from the CLR state. – Hans Passant Sep 08 '13 at 11:07
  • Using WinDbg I found that the exception is `Could not load file or assembly 'MyProj.XmlSerializers, Version=3.2.7428.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.`. I can guess that CLR is responsible for loading this dll and not OS and therefore CLR will have more info about the dll that he couldn't load, right? But, because I registered VEH handler shouldn't it receive the whole exception description? – theateist Sep 08 '13 at 12:22
  • You cannot reliably use VEH handlers in a managed program. .NET uses SEH as well and you'll see exceptions that you should *never* look at or mess with. Like this one, searching for an XML serializer frequently causes exceptions as explained in [this answer](http://stackoverflow.com/a/3798614/17034). VEH is a pretty ho-hum feature, at best only useful for diagnostic tools. – Hans Passant Sep 08 '13 at 12:28
  • I do use VEH for diagnostic tools. I need to know in VEH handler that the exception I get is the one related to XML serializer and ignore it. I thought to check if there is `.PAVEEFileLoadException@@` string but it's not reliably because it can also be related to not only to XML serializer – theateist Sep 08 '13 at 12:53
  • Use the AppDomain.FirstChanceException event instead. – Hans Passant Sep 08 '13 at 12:57
  • I cannot NOT to use VEH handler. In general, I read about how SEH and VEH are registered, but I didn't understand how VEH handler is informed when CLR cannot load dll. Does CLR loader use any OS functionality and thus when dll is missing OS informs VEH? – theateist Sep 08 '13 at 13:31

0 Answers0