2012-12-13 42 views
1

我正在編寫Windows服務。windows服務項目名稱空間'System.Configuration'中不存在類型或命名空間名稱'ConfigurationManager'

添加了dll和命名空間如下所示。

using System.Configuration;

//此行導致錯誤,但爲什麼?

var settings = System.Configuration.ConfigurationManager.AppSettings;

錯誤:類型或命名空間名稱ConfigurationManager中'不存在命名空間中存在「System.Configuration」

項目的目標是4.0版,我成功地安裝和啓動服務

感謝。

+0

你看到ConfigurationManager的dll在安裝位置?也看看這裏似乎dup問題http://stackoverflow.com/questions/1274852/the-name-configurationmanager-does-not-exist-in-the-current-context – paragy

+0

謝謝我認爲有我的配置中缺少AppSettings。我現在添加了它。 –

回答

1

appSettings是隻讀屬性,所以我們需要在App.config中定義我的想法。

<?xml version="1.0"?> 
<configuration> 
<appSettings> 

</appSettings> 
.... 
<system.webServer> 
    <modules runAllMan.... 
相關問題