与&QUOT App.Config中的错误;配置系统初始化失败" [英] App.Config errors with "Configuration system failed to initialize"

查看:215
本文介绍了与&QUOT App.Config中的错误;配置系统初始化失败"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在.NET 4.0中它有一堆的,我想搬到App.Config中(所以它会在同一个地方)的变量在C#编写一个控制台应用程序。新增的这部分代码为App.Config中(配置标签之间):

I have a console application written in C# under .net 4.0 It has a bunch of variables which I want to move into App.Config (so it will be all in one place). Added this part of code to App.Config (between configuration tags):

<configuration>
  <appSettings>
    <add key="RemoteDirectory" value="Some Text Here"/>
  </appSettings>
</configuration>

在我的程序试图使用此代码

In my program trying to test it with this code

Console.WriteLine(ConfigurationManager.AppSettings["RemoteDirectory"]);



但我不断收到配置系统初始化失败的错误。

but I keep getting "Configuration system failed to initialize" error.

推荐答案

尝试寻找内部异常的更多详细信息。它帮助我,当我有同样的烦恼。

Try looking the Inner Exception for more detailed information. It helped me out when I had this same trouble.

此外,检查格式是否为您正在使用您的项目.NET框架是正确的。如果您使用的框架4.5它看起来应该像下面这样:

Also, check if the format is correct for the .net Framework you are using on your project. If you're using the framework 4.5 it should look like the one below:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <appSettings>
    <add key="RemoteDirectory" value="Some Text Here" />
  </appSettings>
</configuration>

这篇关于与&QUOT App.Config中的错误;配置系统初始化失败&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆