C#:配置文件错误

ent*_*thu 0 c# config

我创建了一个.config文件,其中没有给出任何<configuration>标记.它在我的项目中工作正常.但是现在当我为项目创建单元测试用例时,它给出了一个project.dll没有<configuration>标记的异常.如果我在.config文件中包含标记,则项目会出错.我正在使用vs-2008.我创建的.config文件为:

<?xml version="1.0" encoding="utf-8" ?>
  <appSettings>
....
.....
</appSettings>
Run Code Online (Sandbox Code Playgroud)

如果我<configuration>.config文件中使用标记错误来自项目,测试用例工作正常.错误来自:

根元素必须与引用文件的部分名称'appSettings'匹配

当我删除<configuration>标记时,错误在单元测试用例中出现:

unit test runner failed to  load test assembly.
jetbrains.resharper.taskrunnerframework.taskexception.configuration system fail to initialize.
jetbrains.resharper.taskrunnerframework.taskexception.configuration file project.dll doesnot have <configuration> tag.
Run Code Online (Sandbox Code Playgroud)

Kev*_*vin 7

你需要包装<appSettings>一个<configuration>部分.例如:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <appSettings>
    ...
   </appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)