The type initializer for 'MyClass' threw an exception
Check the InnerException
property of the TypeInitializationException
; it is likely to contain information about the underlying problem, and exactly where it occurred.
This problem can be caused if a class tries to get value of a key in web.config or app.config which is not present there.
e.g.
The class has a static variable
private static string ClientID = System.Configuration.ConfigurationSettings.AppSettings["GoogleCalendarApplicationClientID"].ToString();
But the web.config doesn't contain the GoogleCalendarApplicationClientID
key
The error will be thrown on any static function call or any class instance creation