8

When running MassTransit in ASP.NET. A NullReferenceException is being thrown, as per the issue reported here: Google Discussion Group

Relevant Detail
Does anybody know how to gracefully catch the exception when the AppDomain reloads?

The stack trace only goes as far as the MassTransit DLL:

NullReferenceException in ThreadPoolConsumerPool

Locating source for 'd:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit\Threading\ThreadPoolConsumerPool.cs'. (No checksum.)
The file 'd:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit\Threading\ThreadPoolConsumerPool.cs' does not exist.
Looking in script documents for 'd:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit\Threading\ThreadPoolConsumerPool.cs'...
Looking in the projects for 'd:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit\Threading\ThreadPoolConsumerPool.cs'.
The file was not found in a project.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\'...
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: d:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit\Threading\ThreadPoolConsumerPool.cs.
The debugger could not locate the source file 'd:\BuildAgent-03\work\8d1373c869590c5b\src\MassTransit\Threading\ThreadPoolConsumerPool.cs'.
Sk93
  • 3,676
  • 3
  • 37
  • 67
Paul
  • 1,483
  • 14
  • 32
  • 1
    You may want to add the relevant parts of the discussion here. Link-only answers are not a good fit for this site and I don't believe Link-only questions are much better. – nvoigt Dec 03 '13 at 10:39
  • 1
    nvoigt - I've added the relevant detail – Paul Dec 03 '13 at 13:52
  • This is only a suspicion but I think that Mass Transit interferes with the worker thread pool ASP.NET uses to handle requests. We had a similar issue with calling web services from within the ASP.NET application with asynchronous delegates - under high load the pool was ultimately depleted and the performance was terrible. Does it happen under high load or always? – Wiktor Zychla Dec 03 '13 at 14:08
  • Wiktor - this is during development under minimal load – Paul Dec 03 '13 at 14:10

1 Answers1

1

You should be able to catch any uncaught exception in global.asax: http://msdn.microsoft.com/en-us/library/24395wz3(v=vs.100).aspx

Implement the error handler:

void Application_Error(object sender, EventArgs e)

and mark the exception as handled:

Server.ClearError();
Paul
  • 1,483
  • 14
  • 32
Eugene Tolmachev
  • 822
  • 4
  • 14
  • If you publish the whole stack trace, maybe it will show that the exception happens before Application gets a chance to wireup the error handler. In that case you might be able to delay MT initialization till after the app had a chance to setup. – Eugene Tolmachev Dec 04 '13 at 17:52
  • no, the application has definitely passed application_start and has been running for a substantial period each time this occurs. – Paul Dec 11 '13 at 08:36
  • a stack trace can be seen in the screen shot on the referenced link in my original question. – Paul Dec 11 '13 at 08:37
  • how about http://msdn.microsoft.com/en-us/library/system.appdomain.unhandledexception(v=vs.110).aspx? – Eugene Tolmachev Dec 11 '13 at 15:49