2011-08-07 4 views
1

동일한 솔루션으로 두 개의 프로젝트가 있습니다. 하나의 프로젝트를 사용하여 두 번째 프로젝트의 app.config 파일을 업데이트합니다. GetSection 메서드와 ClientSettingsSection 클래스를 사용하여 필요한 값을 읽을 수 있지만 이러한 값을 업데이트하는 방법을 찾을 수 없습니다.런타임에 app.config의 값을 업데이트하십시오.

답변

2
ConfigurationManager.RefreshSection(sectionName); 

+0

값은 두 번째 프로젝트의 속성에 입력되었습니다. 나는 그 자산의 가치를 얻을 수 있었지만 그것을 수정하는 방법을 알 수 없었다. RefresSection은 부동산의 가치를 어떻게 수정합니까? – Guy

0

당신은 같은 것을 할 수 있습니다

Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); 
config.AppSettings.Settings.Add("MyKey", "MyValue); 
config.Save(ConfigurationSaveMode.Modified); 

그러나 당신이 ConfigurationManager.RefreshSection() 메서드를 호출 할 필요가 있도록 응용 프로그램 구성 파일, 캐시 : 나는를 수정하기 위해 노력하고있어 http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.refreshsection.aspx

+0

appSettings 섹션에없는 키를 수정하려고하는데 다른 섹션에서는 GetSection 메서드를 사용했습니다. 코드가 appSettings 섹션에 키를 추가합니다. 더 정확히 말하면 두 번째 프로젝트의 Properties에 입력 된 키를 수정하려고합니다. – Guy

관련 문제