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

查看:33
本文介绍了更改 .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.

鉴于此,一种选择可能是从您的 Main 功能中创建一个新的应用域,并将域配置为使用您需要的 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天全站免登陆