配置系统初始化失败
我是 Visual Studio 和 MySQL 的新手。我在想是否有人可以告诉我这段代码有什么问题。
app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<add key="ODBCDriver" value="Driver={MySQL ODBC 5.1 Driver};Server=localhost;"/>
<add key="DataBaseDetails" value="Database=timekeeping;uid=root;pwd=admin;Option=3;"/>
<configSections>
<sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
</sectionGroup>
</configSections>
</configuration>
出现错误,指出配置系统无法初始化。
请帮忙。
I'm new to Visual Studio and MySQL. I'm thinking if somebody can tell me what's wrong with this code.
app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<add key="ODBCDriver" value="Driver={MySQL ODBC 5.1 Driver};Server=localhost;"/>
<add key="DataBaseDetails" value="Database=timekeeping;uid=root;pwd=admin;Option=3;"/>
<configSections>
<sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
</sectionGroup>
</configSections>
</configuration>
There is an error stating Configuration system failed to initialize.
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
首先,您不使用 ConnectionString 而不是自定义键是否有原因?
其次,您不能只使用 Appsettings 部分来定义您的密钥吗?假设您正在代码中查找它们:
例如。比如:
或者您可以用 userSettings 元素替换 appsettings ?
Firstly is there a reason you're not using a ConnectionString instead of custom keys?
Secondly can't you just use an Appsettings section to define your keys? Assuming you are looking them up in your code:
eg. like:
or you might just be able to replace the appsettings with your userSettings element?
这对我有用。
确保您的 app.config 或 web.config 以选项卡内的标记开始,例如
,在您的情况下,您在此之后没有结束标记
,请确保项目的 targate Framework 属性不得为客户资料
This work for me.
Make sure that your app.config or web.config start with the tag inside the tab e.g
and in your case you have not end the tag
after that make sure taht targate Framework property of your project must not be client profile
我出现此问题的原因是 MySql.Data.dll 和 .Net Framework 版本不兼容。当我找到 .NET 5 的最新版本 MySql.Data.dll 后,这个问题就消失了。在更改 dll 之前,我尝试了配置文件内和外的各种建议,但没有成功。
My reason for this issue was incompatibility between MySql.Data.dll and .Net framework version. Once I found lates version of MySql.Data.dll for .NET 5, this issue gone. Prior to change dll I gave a try to various suggestions within and without config file, with no luck.