Fixing the "TypeInitializationException was unhandled" exception

Fixing the "TypeInitializationException was unhandled" exception

I ran into this issue today so I thought I'd share.

According to the docs:

When a class initializer fails to initialize a type, a TypeInitializationException is created and passed a reference to the exception thrown by the type's class initializer. The InnerException property of TypeInitializationException holds the underlying exception. TypeInitializationException uses the HRESULT COR_E_TYPEINITIALIZATION, that has the value 0x80131534. For a list of initial property values for an instance of TypeInitializationException, see the TypeInitializationException constructors.

This error occured in my project because I had elements in my App.config file that were not recognized. This is most commonly caused by using an invalid setting in the config file.

Once I removed the invalid elements, everything worked fine again.

If you are having this problem, double-check your App.config file and make sure you haven't included anything wrong.

Happy debugging, I hope this solves your problem.

Robert Greiner

Robert Greiner

Professional optimist. Passionate about cultivating high-performing teams @ scale by integrating the timeless wisdom of the past with the marvel of today's emergent technology in a practical way.

View Comments
Next Post

Putting the Three Rules of TDD Into Practice

Previous Post

Practice Better

Subscribe for free

Subscribe to my newsletter and get the latest posts delivered right to your inbox for free. I don't spam and your email won't be shared with third-parties.

Thanks for subscribing!

Check your inbox to confirm your subscription.

Please enter a valid email address!