1

我编写了一个简单的 wpf 应用程序,用于在 datagrid 中绑定数据。在下一行运行时会引发错误。

string ConString = System.Configuration.ConfigurationManager
                         .ConnectionStrings["ConString"].ToString();

异常显示:Exception has been thrown by the target of an invocation."

InnerException:{"Object reference not set to an instance of an object."}

4

1 回答 1

1

可能 System.Configuration.ConfigurationManager.ConnectionStrings["ConString"] 为 NULL 或 System.Configuration.ConfigurationManager.ConnectionStrings 为 NULL。

于 2012-06-01T11:05:49.857 回答