RSS

Same Error in NUnit: The Type Initializer for … Threw an Exception (And app.config)

26 Jul

I have already copied app.config file as instructed here but still get the same error. So, what could be the problem here?

Apparently, this error simply means the system not able to access database, namely: Connection String problem.

This is how I access my connection string:

System.Configuration.ConfigurationSettings.AppSettings.Get("DatabaseEntities");

Above code will not return the connection string I have in web.config file. I use Entity Framework and in Entity Framework, the correct way to get connection string is:

System.Configuration.ConfigurationManager.ConnectionStrings["DatabaseEntities"].ConnectionString;
Advertisements
 
2 Comments

Posted by on July 26, 2011 in General

 

Tags: , , , , ,

2 responses to “Same Error in NUnit: The Type Initializer for … Threw an Exception (And app.config)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: