클래스 라이브러리를 생성했다고 가정합니다. 그것은 당신 같은가는 설정 속성을 정의했습니다 :
Properties.Settings.Default.ProjectName
다음과 같이 스튜디오가 자동으로 당신을 위해 몇 가지 구성을 생성 할 수 있습니다 시각 :
(의 app.config)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="MyDllProject.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<MyDllProject.Properties.Settings>
<setting name="ProjectName" serializeAs="String">
<value>MyDllproject</value>
</setting>
</MyDllProject.Properties.Settings>
</applicationSettings>
</configuration>
이제이 어셈블리를 프로젝트에 추가한다고 가정 해보십시오. 그리고 설정에 액세스하면 아마도 MyDllproject
이됩니다. 이것은 모든 구성을 추가 함에도 불구하고 있습니다. 왜? 어셈블리가 생성되었을 때 그 어셈블리에 쓰여졌 기 때문에. 작성된 코드는 구성 오버라이드가없는 경우 생성시 app.config에 정의 된 것을 사용하는 코드입니다.
은 이제 대상 프로젝트에, 당신은 단순히 다음과 같은 패턴으로 구성 파일에
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<!-- start: copied from app.config of class library -->
<section name="MyDllProject.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"
/>
<!-- end: copied from app.config of class library -->
<!-- other sections may follow -->
</sectionGroup>
</configSections>
<applicationSettings>
<!-- remember to maintain the same order as how it was defined in the sectionGroup -->
<!-- start: copied from app.config of class librarly -->
<MyDllProject.Properties.Settings>
<setting name="ProjectName" serializeAs="String">
<value>ConsoleProjectB</value>
</setting>
</MyDllProject.Properties.Settings>
<!-- end: copied from app.config of class library -->
<!-- other configurations settings may follow -->
</applicationSettings>
</configuration>
그게 전부가 필요한 부분을 추가합니다. http://sdrv.ms/16ksPef
당신이뿐만 아니라의 Web.config의 사본을 게시 할 수 없습니다 : 여기
내가 같은를 위해 연결 한 작은 프로젝트 샘플입니다. –web.config에서 'connectionStrings'섹션을 표시 할 수 있습니까? – Egor4eg
질문을하고 결코 당신을 도우려는 사람들과 상호 작용할 수 없습니다! – lKashef