简体   繁体   English

空引用异常未处理

[英]Nullreference exception was unhandled

I am creating a microsoft WPF project and ran into the following hindrance: 我正在创建一个Microsoft WPF项目,遇到以下障碍:

Null reference was unhandled Object reference not set to an instance of an object 空引用未处理对象引用未设置为对象的实例

My VS 2010 points to the following line of code: 我的VS 2010指向以下代码行:

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. ConnectionStrings参数Lab06Wpf.Properties.Settings.AppConnectionString有效,并且连接已经过测试。

Any leads anyone? 有带头人吗?

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

That is returning null and your are calling ConnectionString on it. 那将返回null,并且您正在对其调用ConnectionString You need to find out why it is returning null. 您需要找出为什么它返回空值。 Use your debugger to see what ConnectionStrings contains and why your call is failing. 使用调试器查看ConnectionStrings包含的内容以及调用失败的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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