2012-06-20 25 views

cevap

5
var configuration = WebConfigurationManager.OpenWebConfiguration("~"); 
var appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings"); 
3

yılında o ConfigSource özelliğini değiştirmek gerekir çünkü

ama AppSettingsSection nesne gerekir.

string sectionName = "appSettings"; 
var config = 
    ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); 
AppSettingsSection appSettingSection = 
    (AppSettingsSection)config .GetSection(sectionName); 
+2

yazmak için tip 'System.Configuration.KeyValueInternalCollection' nesne artığını açılamıyor 'System.Configuration.AppSettingsSection:

Eğer ConfigurationManager.Open... veya WebConfigurationManager.Open... yöntemleri kullanmaları gerekmektedir Configuration nesneyi almak için '. – Bohdan

+0

@Bohdan evet haklısın cevabımı güncelledim. – nemesv

İlgili konular