System.ServiceModel Type Initialization Exception
Technology February 23rd, 2009
I was attempting to do rebuild of a WPF client application I’m building, and started getting this all of a sudden:
A System.TypeInitializationException error occured at System.ServiceModel: The type initializer for 'System.ServiceModel.ClientBase`1' threw an exception.
I have a client class that I use to put all of my service calls in. This class inherits from System.ServiceModel.ClientBase. It was the instantiation of this class which was throwing the exception.
Turns out I had changed the App.config to add some WCF logging in there, and had forgotten to enclose the bit in a <system.diagnostics> tag. Oops. Anyway, I’ve seen this before - configuration errors will throw type initializer exceptions in classes that inherit from ClientBase and ServiceHost. Fixing the error in my App.config fixed the exception.
Teaches me to go longer than an hour without making a build!

About