开发者

sharing library App.Config

I have a DLL, that Dll needs so开发者_开发知识库me configurations to work, mostly for WCF.

im using this DLL in several applications, how can i combine that dll's app.config into the applications app.config?

Thank you.


In your app config for the dll, you will need to copy two pieces. Paste these into the application's app.config file.

First, you need the declaration near the top. You will most likely need to merge these into the existing configuration sections for your application.

<configuration>
  <configSections>
    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <section name="MyApplication.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    </sectionGroup>
</configSections>

Then, you have your actual configuration section at the same level as configSections

<applicationSettings>
<MyApplication.Settings>
  <setting name="Setting1" serializeAs="String">
    <value>hello world</value>
  </setting>
  <setting name="Setting2" serializeAs="String">
    <value>This is my value!</value>
  </setting>
</MyApplication.Settings>
</applicationSettings>

The application configuration for the executing app will automatically supersede your dll's app.config.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜