2009-02-05 4 views
1

ServicedComponent를 구현하는 .Net 구성 요소를 호스팅하는 COM + 서버가 있습니다.사용자 지정 ConfigurationSection을 사용하는 COM + 서버 구성

COM + 서버는 사용자 지정 구성 섹션이 정의 된 구성 파일에 액세스해야합니다.

나는 다음과 같은 코드로 구성 벌금을로드 할 수

ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap(); 
fileMap.ExeConfigFilename = @"%MY_FOLDER_WITH_ALL_DLLS%\MyComServer.dll.config"; 
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); 

// All is fine until the next line: 

MyCustomSettings customSettings = (MyCustomSettings)tempConfiguration1.GetSection("customSettings"); 

System.InvalidCastException을 : 입력 유형 'System.Configuration.DefaultSection'의 개체를 캐스팅 할 수 없습니다 'MyProject.MyCustomSettings'

다음은 구성 파일에서 사용자 지정 구성 섹션을 선언 한 방법입니다.

<configSections> 
    <section name="MyProject.MyCustomSettings" type="MyProject.MyCustomSettings, MyProject, Version=1.0.3322.1077, Culture=neutral, PublicKeyToken=176fc8b9840b0b09"/> 
</configSections> 

이 경우 실제로 doS CustomSettings 객체를 기대하고 있기 때문에별로 사용하지 않는 것 같습니다.

MyProject의 이름이 강력하다는 점에 유의하십시오.

MyProject.dll 어셈블리를 GAC에 설치하는 옵션이 있지만 조직적 이유로이 솔루션은 매력적이지 않습니다.

다른 제안 사항이 있습니까?

DLLHost에서 실행되는 프로세스에서 주어진 어셈블리의 구성 파일에서 사용자 지정 구성 섹션을로드하려면 어떻게해야합니까?

감사합니다.

답변

0

나는이 문제로 몇 시간을 낭비했습니다. 마지막으로 < configSection>을 < 구성 바로 아래로 이동하여 해결했습니다. 이번에는 < configSection> 위에 다른 구성 요소가있었습니다.

관련 문제