2017-03-09 60 views
1

我試圖使用ConfigurationManager,起初System.Configuration沒有它,我想知道爲什麼。爲什麼沒有ConfigurationManager?

enter image description here

一些嘗試後,經過包括參考System.Configuration現在表現出來。

enter image description here

因此,如何我可以使用System.Configuration沒有參考?但需要參考使用System.Configuration.ConfigurationManager

enter image description here

+1

這是什麼類型的項目?你的目標是什麼框架版本?你確定你的參考文獻是拼寫完善嗎? – maccettura

+2

在多個程序集中可能有相同的名稱空間。 –

+3

你是如何添加該參考的?奇怪的是它是'System.configuration'而不是'System.Configuration'。 – mason

回答

2

在原有System.Configuration名稱空間分開。 net1.0和1.1的命名空間System.Configuration在System.dll之下。
由於.net2.0有一個新的程序集 - System.Configuration.dll

回到當天我們不得不使用ConfigurationSettings,這是在System.dll大會,現在已經過時了。
現在,我們使用ConfigurationManager及其在System.Configuration.dll程序集中。

因此,您得到System.Configuration的原因可能是因爲您引用了System.dll,它在默認情況下包含在winforms應用程序中。

1

任何組件可導出任何命名空間。

MyFoo.dll可以命名空間如System.Configuration.VeryImportant.Type,這意味着,如果引用MyFoo.dll System.Configuration是一個有效的命名空間中定義的類型,即使ConfigurationManager類型在System.Configuration.dll組件內限定。

默認情況下還包括其他程序集,其中可能包括System.Configuation作爲導出的名稱空間。

2

這是因爲命名空間跨幾個組件

您可能已經獲得從mscorlib.dll程序集,或類似的核心DLL