[英]configuration system failed to initialize in visual studio 2010 windows form
I'm currently facing this error while running my c# program: 我目前在运行c#程序时遇到此错误:
configuration system failed to initialize
here is my app.config file: 这是我的app.config文件:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<add name="FastConnection"
connectionString="DataSource=.\SQLEXPRESS;AttachDbFilename=C:\Users\mustiondb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" />
</configSections>
</configuration>
I believe there is probably information lacking in this app.config file. 我相信此app.config文件中可能缺少信息。 However, I'm not sure what information.
但是,我不确定什么信息。 When I created an app config file from my windows form (visual studio 2010), the only information in the app config file was this:
当我从Windows窗体(Visual Studio 2010)创建应用程序配置文件时,应用程序配置文件中的唯一信息是:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>
I tried searching for information to add in, but i'm not sure what and where to find these information. 我尝试搜索要添加的信息,但是我不确定在哪里以及在哪里找到这些信息。
If you want to use connection string use <connectionStrings>
not <Configurations>
如果要使用连接字符串,请使用
<connectionStrings>
而不是<Configurations>
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="FastConnection" connectionString="DataSource=.\SQLEXPRESS;AttachDbFilename=C:\Users\mustiondb.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" />
</connectionStrings>
</configuration>
If you need to add custom application settings 如果您需要添加自定义应用程序设置
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="Key0" value="0" />
<add key="Key1" value="1" />
<add key="Key2" value="2" />
</appSettings>
</configuration>
I faced the same issue. 我遇到了同样的问题。 I had an
&
in one of the strings of app.Config and somehow Visual Studio didn't show the error while building. 我在app.Config的字符串之一中有一个
&
,并且Visual Studio在构建时不显示错误。 After replacing &
with &
用
&
替换&
之后&
it worked fine. 工作正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.