vendredi 8 juillet 2016

System.TypeInitializationException: The type initializer threw an exception

I am trying to access the a class function from another project to unit test project in visual studio. But it's show exception at run time:-

[System.TypeInitializationException] = {System.TypeInitializationException: The type initializer for 'MyDoc.Insert' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object.

My Code given below:

SqlTransaction transaction;
SqlConnection con = new SqlConnection(dbConnString);
con.Open();
transaction = con.BeginTransaction();
Insert insobj = new Insert();//Exception generate here 
rowid = insobj.AffiliationInsert("SP_AFFILIATIONS", "testaff", con, transaction);
Assert.AreEqual(54, rowid);

catch (Exception ex) {
    throw ex;
}

Please suggest me how to solve this problem.

Aucun commentaire:

Enregistrer un commentaire