2012-04-12 3 views
1

나는 (웹 사이트 | windows) 응용 프로그램과 dll (classlibrary)을 가지고 있습니다. 나는 dll에서 루트 (웹 사이트 | windows) 설정 파일 경로를 얻고 싶다.dll에서 루트 구성 파일 경로 가져 오기

다른 Assembly.get과 함께 ConfigurationManager.OpenExeConfiguration을 시도했지만 항상 DLL 구성 경로를 제공합니다.

감사

답변

0

안녕하세요이를 발견하고는 그 경우 웹 사이트의 Web.config를 얻을 것이다 그것의 경우 윈도우 응용 프로그램

을 app.exe.config 얻을 것이다 잘

Configuration config; 

     if (System.Web.HttpContext.Current != null && 
      System.Web.HttpContext.Current.Request.PhysicalPath.Equals(String.Empty) == false) 
     { 
      config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(HttpRuntime.AppDomainAppVirtualPath); 
     } 
     else 
     { 
      config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); 
     } 

Basicly를 작동

관련 문제