Resolved: Event Type clr20r3, .NET Runtime Error, Event ID 5000

By dsandor at July 16, 2009 23:53
Filed Under:

Funky error received:

Windows Service failed to start and logged an Event ID 5000 in the Application Event log with the following details:

EventType clr20r3, P1 devsql.replicatorservice.exe, P2 1.0.3293.22912, P3 49639851, P4 devsql.replicatorservice, P5 1.0.3293.22912, P6 49639851, P7 f, P8 8, P9 system.typeinitialization, P10 NIL.

 

Note P9 is key here.  If you googled this event ID and you do not have a system.typeinitialization error as P9 this blog entry will NOT help you.  My only advice to you is this:  Debug your code, try catch the heck out of your code, or follow this thread's advice for creating an unhandled exception handler (oxymoron?):

http://social.msdn.microsoft.com/Forums/en-US/clr/thread/f165f3fc-8107-4e39-b2b0-0375370a5a07/

 

So first you must understand that this error occurred (for me) when a static constructor (or static field initializer) is trying to create a type and fails.  It happens too quick to catch in your service and even if you debug the heck out of it you still won't be able to catch it properly because it is thrown from a static.

Check any lines of code that initialize a static variable / object.

In my case the problem was log4net references in my code:

private static readonly ILog log = LogManager.GetLogger(typeof(Signaler));

log4net is actually GAC'ed on my dev machine so it did not include the log4net assembly in the output ( ./bin/Debug ) folder.  I XCOPIED the debug folder to my test machine, installutil'ed the service and it failed to start. 

Copying the log4net assembly to the test server fixed my problem.  This allowed the static initializer to create the log4net reference and viola!

Comments are closed