2011-08-03 5 views
-1

라이브러리 프로젝트에서 구성 파일을 사용하여 해당 인터페이스를 자체 클래스에 연결합니다. 내 응용 프로그램 구성에서 아무것도로드 할 수 없기 때문에 나는 문제가 있습니다.C# 응용 프로그램에서 구성 파일을로드 할 수 없습니다.

<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <appSettings> 
    <add key="Sic2Lib.it.carrefour.sic.profiler.datasource.def.AuthenticateDS" value="Sic2Lib.it.carrefour.sic.profiler.datasource.impl.AuthenticateDSImpl"/> 
    <add key="Sic2Lib.it.carrefour.sic.profiler.datasource.def.CheckUserDS" value="Sic2Lib.it.carrefour.sic.profiler.datasource.impl.CheckUserDSImpl"/> 
    <add key="Sic2Lib.it.carrefour.sic.profiler.datasource.def.ReadApplicationConfigDS" value="Sic2Lib.it.carrefour.sic.profiler.datasource.impl.ReadApplicationConfigDSImpl"/> 

된 DataSourceFactory 클래스의 같은 디렉토리에 개최 : 여기의 app.config라고 config 파일에서 샘플입니다. 이 클래스는 그래서, 오류없이 프로젝트를 빌드하고 나는 빈/디버그 폴더에 myProject.dll.confing라는 파일을 얻을 명령

NameValueCollection keys = ConfigurationManager.AppSettings; 

을 통해 설정을 할 예정이다. 하지만이 모든 일이 끝나면 항상 변수가 비어있는 키가 생깁니다 ... 어떻게? 지금까지 내가 한 일이 뭐가 잘못 되었 니?

답변

3

라이브러리 프로젝트는 자체 구성이 없으며 라이브러리를 사용하는 응용 프로그램의 구성을 사용합니다.

응용 프로그램 프로젝트의 구성 파일에 구성 설정을 입력하면됩니다.

+0

글쎄, 내 응용 프로그램에 제대로로드하려면 설정 파일이 필요합니다 ... 나중에 라이브러리로 사용됩니다. –

+0

@Dharma Dude - 설정 파일의 이름은 응용 프로그램의 이름과 일치해야합니다. 그래서 앱이'example.exe'라면 설정 파일 이름은'example.exe.config'입니다. – Oded

관련 문제