0

I have a WebAPI application where we often drop various custom dlls into the bin folder for additional functionality. Sometimes the custom dlls reference other custom dlls, which reference other custom dlls... it can be a bit of a nightmare.

Occasionally I will either miss something, or something goes screwy, and I get the infamous YSOD (Yellow Screen Of Death) upon starting the API.

screenshot

The YSOD will often display the name of the troublemaker assembly, which helps a little, but what I really want to know is the dll(s) that I'm missing. And I know that I can get this information from the LoaderExceptions property if only I could catch and handle the exception!!

I've got a lot of exception handling at a few different levels, including a global exception handler, but after trying quite a few different things, and finding this (so far) unanswered question, I'm getting a nasty suspicion that this exception is occurring in IIS outside of my app, and I have no control over it.

If that IS the case, is there a way I can examine the exception in IIS? Otherwise why would it suggest retrieving the LoaderExceptions?

If NOT the case, how/where/when can I catch and handle this type of exception?


EDIT:

From David's comment below, I have also tried hooking to AppDomain.AssemblyResolve, AppDomain.UnhandledException, and AppDomain.FirstChanceException events, and none of these are catching the yellow screen exception either...

Community
  • 1
  • 1
sǝɯɐſ
  • 2,470
  • 4
  • 33
  • 47
  • Have you tried the `AppDomain.AssemblyResolve` event? That event gets raised when an assembly can't be found: https://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve(v=vs.110).aspx – David Sep 03 '15 at 19:32
  • @David, I just tried to hook to that in my `Application_Start()`, and it's not working for me. I also tried hooking to [AppDomain.UnhandledException](https://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.110).aspx), and [AppDomain.FirstChanceException](https://msdn.microsoft.com/en-us/library/system.appdomain.firstchanceexception(v=vs.110).aspx), and neither of those caught the exception either... as far as I know, `Application_Start()` is the entry point, but maybe the exception is being thrown before that? – sǝɯɐſ Sep 03 '15 at 20:25
  • I don't even hit my `Application_Start()` breakpoint when I refresh the screen when it errors out... which is partly what is making me think it's happening in IIS? I don't know enough about what magic (or lack thereof) is happening behind the scenes in a WebAPI app... – sǝɯɐſ Sep 03 '15 at 20:28

0 Answers0