How can the answer be improved? static class type initializer threw exception The type initializer for threw an exception. means that the static constructor on that class threw an Exception so you need to look either in the static constructor of the CSDetails class, or in the initialisation of any static members of that class.
The type initializer of a static class is the code that sets the values of its static variables. In your case, it is this code: public static readonly string ConsKey public static readonly string ConsSecret static class type initializer threw exception
is usually thrown when a static field of the class can't be initialized. For example: class BadClass private static MyClass fieldName new MyClass(); Will cause a prior to the first usage of BadClass if the constructor for MyClass throws. C# the type initializer for (Static Class) threw an exception; Only on some PCs. Upon initalization of a static class, some users are crashing out with the Type Initializer threw an exception . However, most users are not experiencing any issues. This is production code with tens of thousands of users. The code that initializes your class (in the initializers for the fields or in a static constructor) threw an exception. You can see the actual exception in the InnerException property, or by telling the debugger to break whenever an exception is thrown in Debug, Exceptions. static class type initializer threw exception Public Class Example Shared test As New TestClass(3) Public Shared Sub Main() Dim ex As New Example() End Sub End Class Public Class TestClass Public ReadOnly Value As Integer Public Sub New(value As Integer) If value 1 Then Throw New Value value End Sub End Class ' The example displays the Jan 28, 2010 I have a static class. The class has a static constructor but it is completely empty. static DataAccessFactory() But when I call the static method GetSelectStatement from DataAccessFactory, I get the error: The type initializer for threw an exception. Static classes with static constructor throws: The type initializer for 'class' threw an exception , but debugger sees the data I am trying to use a static class I named 'universal' which contains reference strings and a dictionary. Aug 21, 2012 Question. create instance of PUB class and unwrap (PUB inherits from. . MarshByRef. . ) PUB. method() call on the method from PUB class, now this will call on other objects to do work, and eventually one of the object threw exception 'The type initializer for 'Class' threw an exception