2012-03-27 2 views
3

.net 4.0 프로젝트의 configSection을 설정하려고합니다. 그러나.net 4.0에서 configSection을 설정하는 방법

<configuration> 
    <configSections> 
    <section name="MonitorFldrSection" 
     type="System.Configuration.NameValueFileSectionHandler, System, Version=4.0.0.0" 
      allowLocation="true" 
      allowDefinition="Everywhere"/> 
    </configSections> 
    <MonitorFldrSection> 
    <add name="fldr1" value="C:\Temp" /> 
    <add name="fldr2" value="C:\Projects" /> 
    </MonitorFldrSection> 
    <connectionStrings> 
    </connectionStrings> 
    <appSettings> 
    </appSettings> 
</configuration> 

, 나는 키를 추가 할 때, 내가 지시 얻을 모든 의견 또는 내가

object obj = ConfigurationManager.GetSection("MonitorFldrSection"); 

나는이 오류 코드에 액세스하려고 할 때 CDATA가

메시지를 표시 : { "MonitorFldrSection의 구성 섹션 처리기를 만드는 동안 오류가 발생했습니다 : 파일 또는 어셈블리 'System, Version = 4.0.0.0'또는 해당 종속성 중 하나를로드 할 수 없습니다. 시스템이 지정된 파일을 찾을 수 없습니다 (C : \ Projects_4.0 \ NasImageIndexer \ TestForm \ bin \ Debug \ TestFor m.exe.Config line 5) "}

NameValueFileSectionHandler와 함께 AppSettingsSection 및 DictionarySectionHandler도 시도했습니다.

내가 뭘 잘못하고 있니?

답변

0

이 파일은 C : \ Projects_4.0 \ NasImageIndexer \ TestForm \ bin \ Debug \ TestForm.exe.Config 위치에서 찾을 수 있습니까?

설정 파일 빌드 작업의 속성이 변경되지 않으면 - 콘텐츠 복사 출력 디렉터리에 - 항상

편집 복사 :

이 공개 키 토큰을 추가 한 후 나를 위해 일을하고 이름을 키로 변경하십시오.

<configuration> 
    <configSections> 
    <section name="MonitorFldrSection" 
type="System.Configuration.NameValueFileSectionHandler, System, Version=4.0.0.0,   Culture=neutral, PublicKeyToken=b77a5c561934e089" 
     allowLocation="true" 
     allowDefinition="Everywhere"/> 
</configSections> 
<MonitorFldrSection> 
<add key="fldr1" value="C:\Temp" /> 
<add key="fldr2" value="C:\Projects" /> 
</MonitorFldrSection> 
<connectionStrings> 
</connectionStrings> 
<appSettings> 
</appSettings> 
</configuration> 
+0

예, TestForm.exe.Config를 찾을 수 있지만 여전히 getti ng 같은 오류 – edepperson

+0

그것은 어리석은하지만 당신이 릴리스 모드에서 실행중인 경우 디버그 모드에서 bin \ release를 확인 bin \ release를 확인하는 바보 같은 일이지만,이 실수를 여러 번 했어 – Kiru

+0

뭐라고, 내 시스템을로드 할 수 없습니다, 버전 = 4.0.0.0이지만 해당 파일은 C : \ Program Files \ Reference Assemblies \ Microsoft \ Framework \ .NETFramework \ v4.0에 있습니다. 그러나 버전은 4.0.30319.1입니다. – edepperson

관련 문제