c# - System.TypeInitializationException: 'The type initializer threw an exception.' -


i've simple class myclass method defined in dll, refer dll in code , try initialise object myclass obj = new myclass(). i'm not sure why compiler throwing nullreferenceexception. please assist

dll:

public class myclass {     public myclass(){}     public void method()     {          //some code     } } 

other code:

void main() {     myclass obj=new myclass(); //this nullreferenceexception error } 

for posterity, since found answer in comments:

typeinitializationexception caused error in static field initialization or static constructor execution.

indeed found inner exception stack trace pointed :

sqlconstr = configurationmanager.connectionstrings["rmdb.database"].conn‌​ectionstring 

this error caused fact connection string rmdb.database not specified in app.config application. connection strings (event used dlls) must specified in app.config of application using connection.


Comments