【发布时间】:2011-04-08 04:47:57
【问题描述】:
我有一个类库,它在 app.config 中包含一个有效的 connectionString。在那个类库中,我想使用它
ConfigurationManager.ConnectionStrings["NAME"].ConnectionString
我的 ASP.net 4.0 框架应用程序引用该 DDL 并从中检索数据。我想使用 App.config 中的 ConnectionString 在我的 DDL 中创建一个 Entity Framework 4 DataContext。 (我不想在每个方法中都从我的 ASP.net 应用程序传递 connectionString。(我正在使用 ObjectDataSources))
但是,我的 DLL 中的这一行会引发 NullReferenceException。
ConfigurationManager.ConnectionStrings["NAME"].ConnectionString
我该如何解决这个问题?
【问题讨论】:
-
只有我觉得查克也在这里很有趣吗???
标签: c# asp.net app-config