config中和混乱的app

config中和混乱的app

本文介绍了web.config中和混乱的app.config的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有引用Web服务的DLL。

I have a DLL that references a web service.

它已经投入的app.config块是(我已经改变了名字,但你的想法):

The block it has put into the app.config is (I have changed the names but you'll get the idea):

<applicationSettings>
    <DLLName.My.MySettings>
        <setting name="DLLName_WebReferenceName_ASMXName"
            serializeAs="String">
            <value>http://URL/Filename.asmx</value>
        </setting>
    </DLLName.My.MySettings>
</applicationSettings>

我的网站引用该DLL。

My website references this DLL.

现在的问题是,我该怎么添加到Web.config覆盖上面的设置(alternativly,我只是把在app.config中的bin目录下)?

The question is, what do I add to the web.config to override the above setting (alternativly, do I just put the app.config in the BIN directory)?

我需要能够覆盖web服务的URL在生产服务器上,因为它无法达到在App.config指定的URL(这是一个不同的问题,我们不会进入)。

I need to be able to override the URL for the webservice on the production server because it can't reach the URL specified in the app.config (that is a different issue we wont go into).

推荐答案

创建configSections所谓的applicationSettings一个新的sectionGroup和粘贴您的app.config配置到web.config中,如下图所示,然后你可以覆盖你的app.config设置。

Create a new sectionGroup in configSections called applicationSettings and paste your app.config configuration into web.config as shown below and then you can override your app.config settings.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <sectionGroup name="applicationSettings"
                type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
            <section name="Playground.ConfigurationOverride.DataAccess.Properties.Settings"
                    type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                    requirePermission="false" />
        </sectionGroup>
    </configSections>
    <applicationSettings>
        <Playground.ConfigurationOverride.DataAccess.Properties.Settings>
            <setting name="MySetting" serializeAs="String">
                <value>Setting in DataAccess</value>
            </setting>
        </Playground.ConfigurationOverride.DataAccess.Properties.Settings>
    </applicationSettings>
</configuration>

这篇关于web.config中和混乱的app.config的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 09:32