Getting Started
Architecture
Transports
Persistence
ServiceInsight
ServicePulse
ServiceControl
Monitoring
Samples

NServiceBus host troubleshooting

Component: NServiceBus Host

Host fails to start due to System.Reflection.ReflectionTypeLoadException

The host does not start and the console or log contains the following exception message:

System.Reflection.ReflectionTypeLoadException Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Details:

Fatal,NServiceBus.Hosting.Windows.WindowsHost,Start failure,"System.Reflection.ReflectionTypeLoadException Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.Assembly.GetTypes()
at System.Linq.Enumerable.<SelectManyIterator>d__17`2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at NServiceBus.Hosting.Profiles.ProfileManager.ActivateProfileHandlers(EndpointConfiguration config) in C:\BuildAgent\work\3fdd02ec65f005b\src\NServiceBus.Hosting.Windows\Profiles\ProfileManager.cs:line 104
at NServiceBus.GenericHost.PerformConfiguration(Action`1 moreConfiguration) in C:\BuildAgent\work\3fdd02ec65f005b\src\NServiceBus.Hosting.Windows\GenericHost.cs:line 82
at NServiceBus.GenericHost.<Start>d__1.MoveNext() in C:\BuildAgent\work\3fdd02ec65f005b\src\NServiceBus.Hosting.Windows\GenericHost.cs:line 53
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at NServiceBus.Hosting.Windows.WindowsHost.Start() in C:\BuildAgent\work\3fdd02ec65f005b\src\NServiceBus.Hosting.Windows\WindowsHost.cs:line 32

Verify that:

  1. Assembly binding redirects in the NServiceBus.Host.exe.config are correct and match with any entries generated in the App.config file.
  2. All files in the deployment (sub)folder are correct and no old files are present from previous deployments.

Service fails to start due to reaching the timeout period

Sometimes when the server hosting a microservice that uses NServiceBus is started, the following exception is seen in windows event viewer.

A timeout was reached (30000 milliseconds) while waiting for the XYZ service to connect. The XYZ service failed to start due to the following error: The service did not respond to the start or control request in a timely fashion

Yet, after a certain period of time, the service is able to start up again without any issues. This happens because during the restart, NServiceBus might still be waiting on some infrastructure to start up before it is able to initialize. This can be mitigated by:

  • Letting the dependencies of a service finish starting up and running before the service.
  • Setting the service to "Automatic Delayed Start" so that it will only get the signal to start when all other “Automatic” services are running. This is because, when a windows service startup is set to "Automatic", it loads during boot whereas when it is set to "Automatic (delayed start)", it does not start until after all other auto-start services have been launched. Once all the automatic start services are loaded, the system then queues the “delay start” services for 2 minutes (120 seconds) by default. This interval can be altered by creating a registry DWORD (32-bit) value named AutoStartDelay and setting the delay (base: decimal) in seconds, in the following registry key:
 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control

Last modified