更改的app.config在运行时 [英] Change app.config at runtime

查看:119
本文介绍了更改的app.config在运行时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在试图创建的app.config在运行。其基本思路是,我部署的几个配置文件,并根据环境变量应用程序本身决定使用哪一个。

I'm currently trying to create the app.config at runtime. The basic idea is that I'm deploying several config files and based on an environment variable the application itself decides which one to use.

目前我复制配置文件,我想用它来myapp.exe.config,并刷新所有章节。 我现在面临的问题是,log4net的似乎搞砸了事情,但只有在发布版本(如静态字段initilized在不同的时间)。

Currently I'm copying the config file I'd like to use to myapp.exe.config, and refresh all the sections. The problem I'm facing is, that log4net seems to mess up things, but only in release build (as the static fields are initilized at a different time).

我明确不想要决定在编译的时候要使用的配置。

I explicitly DON'T want to decide at build time which config to use.

任何想法(可能有更好的方法)?

Any ideas (probably there is a better approach)?

TIA 马丁

推荐答案

您可以配置log4net的你决定使用什么样的配置,并复制到该位置通过XmlConfigurator.Configure(新System.IO.FileInfo(Filename.config后))

You can configure log4net after you decided what config to use and copied it into place by using XmlConfigurator.Configure(new System.IO.FileInfo("Filename.config"))

这篇关于更改的app.config在运行时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆