1

我正在为一个有很多东西要测试的大项目做单元测试。我的项目有 10 个不同的模块。

最初,我App.config在哪里定义了路径和名称ModuleConfiguration.xml以及更多东西......在这个文件中,我有我用于这些测试的所有标签和值。到现在为止,一切OK。

但是我ModuleConfiguration变得非常非常大,所以我决定分开并ConfigurationFile.xml为每个模块设置一个......

例如:

  • 调制解调器模块ModemConfiguration.xml
  • 助手模块HelperConfiguration.xml
  • 等等...

但是我也需要一个App.config用于每个不同的配置文件......

所以,我的问题是如何在我的项目中使用多个 App.config文件......

我在这里先向您的帮助表示感谢!

4

1 回答 1

2

Split the modules up into their own projects, then Add As Link the "main" App.config file:

Sharing App.config across projects

  1. Right-click the project in Solution Explorer
  2. Choose Add -> Existing Item...
  3. Browse to the "main" project that contains the App.config you want to share with this project
  4. Click the filetype dropdown filter and choose All Files (*.*)
  5. Select the App.config
  6. Click the little arrow next to the Add button and choose Add As Link

I already added App.config as a link to Module01 in the screenshot. If you look closely, you'd notice the little shortcut overlay for Module01's App.config - that means that it's linked into the project from another project (in this case, the MyApplication project).

There are other ways to achieve what you want, but I believe this best fits your scenario.

于 2013-09-06T11:48:34.097 回答