2012-09-24 2 views
0

이 메시지는 Cache password for SQL Server connection as a hash의 후속 조치입니다.잠긴 상태에서 구성을 보호 할 수 없습니다.

http://www.codeproject.com/Articles/15392/Implementing-Protected-Configuration-With-Windows은 로컬 Windows 응용 프로그램이 보호 된 구성을 사용하는 방법을 설명합니다. 그러나 내 응용 프로그램이 실행되도록 설계된 환경을 기반으로 설치 프로그램이 바람직하지 않습니다.

나는 다음과 같은 실행 시도했다 : 내 WPF 응용 프로그램에서 여러 다른 시간에

 object settings = ConfigurationManager.GetSection("userSettings/MyApp.Properties.Settings"); 
     SectionInformation info = ((ConfigurationSection)settings).SectionInformation; 
     if (!info.IsProtected) 
      info.ProtectSection("DPAPIProtection"); 

,하지만 난 할 때마다, 나는 VerifyIsEditable에 .NET의 SectionInformation.cs에서이 예외가 :

if (IsLocked) { 
    throw new InvalidOperationException(SR.GetString(SR.Config_cannot_edit_configurationsection_when_locked)); 

. (a) 구성이로드되고 잠기기 전에 ProtectSection()을 실행하거나 (b) Settings.Default.Save()을 호출 한 후 응용 프로그램의 끝에서 구성을 플러시하고 닫은 다음 잠금을 해제 한 다음 ProtectSection()을 호출하는 방법이 있습니까?

답변

0

(나는 정확히 왜 모르겠어요하지만)을 고정 :

 Configuration conf = ConfigurationManager.OpenExeConfiguration 
      (ConfigurationUserLevel.PerUserRoamingAndLocal); 
     ClientSettingsSection settings = (ClientSettingsSection) 
      conf.GetSection("userSettings/MyApp.Properties.Settings"); 
     SectionInformation info = settings.SectionInformation; 

     if (!info.IsProtected) 
     { 
      info.ProtectSection("DPAPIProtection"); 
      info.ForceSave = true; 
      conf.Save(); 
     } 
관련 문제