C#:配置文件错误 [英] C#: Config file error
问题描述
我创建了一个 .config
文件,在其中没有给任何< configuration>
标签。在我的项目中效果很好。但是现在当我为项目创建单元测试用例时,它给出了一个例外,即 project.dll
没有< configuration>
标记。如果我在 .config
文件中包含该标记,则该项目给出了错误。我正在使用vs-2008。我将 .config
文件创建为:
I created a .config
file in which I had not given any <configuration>
tag. It works fine in my project. But now when I created the unit test case for the project, it is giving an exception that project.dll
doesn't have <configuration>
tag. If I include the tag in the .config
file the project is giving an error. I am using vs-2008. I created the .config
file as:
<?xml version="1.0" encoding="utf-8" ?>
<appSettings>
....
.....
</appSettings>
如果我使用< configuration>
标签在 .config
文件中,错误出现在项目中,并且测试用例可以正常工作。错误信息如下:
If I use <configuration>
tag in .config
file the error comes in the project and testcase works fine. the error comes as:
根元素必须与引用
文件的节 appSettings的名称匹配
The root element must match the name of the section referencing the file, 'appSettings'
当我删除< configuration>
标记时,错误出现在单元测试用例中
As I remove the <configuration>
tag, the error comes in unit testcase as:
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.
推荐答案
您需要包装 < appSettings>
在< configuration>
部分中。例如:
You need to wrap the <appSettings>
in a <configuration>
section. e.g.:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
...
</appSettings>
</configuration>
这篇关于C#:配置文件错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!