0

我有两个不同的库,Testlib1并且Testlib2在同一个命名空间中,但我希望它们使用不同的app.config文件。

我可以用两个不同的app.config文件创建一个应用程序吗?

4

3 回答 3

2

只有一个 app.config 和运行时。如果您的程序集具有所需的不同 app.config 部分,则需要将它们传输到主 app.config 文件。

于 2012-09-03T15:17:54.010 回答
1

The app.config file is for the executing application (usually an EXE file or web under IIS), not an assembly. If you want to share settings across multiple applications, see the answer in Is there any way for an App.config file to reference another full config file? (.NET).

于 2012-09-03T08:17:58.817 回答
1

.NET 配置系统的范围是AppDomain,每个 AppDomain 都有自己的配置文件。

因此,如果应用程序在它启动的应用程序之外创建额外的 AppDomains,则可能有一个应用程序使用多个配置文件(有关此类应用程序的示例,请参见NUnit )。

设计和实现多 AppDomain 应用程序并非易事,如果您的唯一目标是分离两个库的配置,则可以使用更简单的方法(但不使用多个完整的配置文件)。

于 2012-09-03T19:39:28.647 回答