简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM