改变.NET应用程序配置文件名 [英] Changing the .NET application configuration file name

查看:108
本文介绍了改变.NET应用程序配置文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个VB6应用程序,它调用.NET程序集,从app.config文件引用的设置。默认情况下,.NET查找VB6应用程序命名的配置文件。要如何把它使用不同的配置文件的名称?这需要成为默认的配置文件,以便如从中读取WCF设置。

I have a VB6 app which calls a .NET assembly, which references settings from the app.config file. By default, .NET looks for a config file named after the VB6 app. How can I redirect it to use a different config file name? This needs to become the default config file so that e.g. WCF settings are read from it.

推荐答案

您不能改变它。每一个AppDomain中实例都有一个固定的app.config正在通过 AppDomainSetup 实例设置,创建一个新的应用程序域的时候。虽然你可以通过设置信息 AppDomain.SetupInformation 已经有效地只读此时成了。

You can't change it. Each AppDomain instance has a fixed app.config that is set via an AppDomainSetup instance when a new app domain is created. Although you can get the setup information via AppDomain.SetupInformation it has effectively become readonly at this point.

鉴于此,一种选择可能是从你的主要函数中创建一个新的应用领域,并配置域使用您需要在app.config。

Given this, one option may be to create a new app domain from within your Main function and configure the domain to use the app.config you require.

这篇关于改变.NET应用程序配置文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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