Parijat
Parijat

Reputation: 1

Nullreference exception was unhandled

I am creating a microsoft WPF project and ran into the following hindrance:

Null reference was unhandled Object reference not set to an instance of an object

My VS 2010 points to the following line of code:

string connectionString = ConfigurationManager.ConnectionStrings["Lab06Wpf.Properties.Settings.AppConnectionString"].ConnectionString;

Not sure why this is happening, I have a similar project where I have a similar connection string and it runs itself just fine.

The ConnectionStrings argument Lab06Wpf.Properties.Settings.AppConnectionString is valid and the connection has been tested.

Any leads anyone?

Upvotes: 0

Views: 395

Answers (1)

Ed Swangren
Ed Swangren

Reputation: 124642

ConfigurationManager.ConnectionStrings["Lab06Wpf.Properties.Settings.AppConnectionString"]

That is returning null and your are calling ConnectionString on it. You need to find out why it is returning null. Use your debugger to see what ConnectionStrings contains and why your call is failing.

Upvotes: 1

Related Questions