开发者

I want to override a property in an external assembly via my config file

开发者_开发知识库

Let's say I have two assemblies: BusinessLogic and Web. BusinessLogic has an application setting called "MySetting".

In my Web assembly's config file, how do I override the setting in BusinessLogic?


You need to add an applicationSettings sectionGroup to the config file:

<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
  <section name="[AssemblyName].Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>

Then you need to add the following:

<[AssemblyName].Properties.Settings>
  <setting name="[SettingToOverride]" serializeAs="String">
    <value>[NewValue]</value>
  </setting>
</[AssemblyName].Properties.Settings>

This allows you to override a setting without the need to redeploy

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜