appSettings 配置部分中不存在密钥“UserID" [英] The key 'UserID' does not exist in the appSettings configuration section

查看:33
本文介绍了appSettings 配置部分中不存在密钥“UserID"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Window Forms 应用程序中尝试在设计器中打开大约 10 个以上的表单中的 2 个时,我突然开始收到此错误.

All of a sudden I start getting this error while trying to open 2 of some 10+ forms in my Window Forms application in designer.

为了防止在加载设计器之前可能丢失数据,必须解决以下错误:appSettings 配置部分中不存在密钥UserID".

To prevent possible data loss before loading the designer, the following errors must be resolved: The key 'UserID' does not exist in the appSettings configuration section.

它曾经工作得很好,我不记得对它做了什么重大改变.

It used to work fine and I dont' remember doing significant changes to it.

当然,关键在 appSettings 中,并且一直如此,并且应用程序按预期构建和执行.只有这两个表单的设计视图无法访问.

The key, of course, is in the appSettings alright, and always was, and the application builds and executes as expected. Only design view for these 2 forms is unaccessible.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>
        <add key="Server" value="MYSERVER" />
        <add key="DataBase" value="MYDB" />
        <add key="UserID" value="MYUSER" />
        <add key="PassWord" value="MYPASS" />
    </appSettings>
</configuration>

其中一个只是一个表单,另一个是一个用户控件.它们都没有继承自抽象类或类似的东西.到目前为止,重建或重新启动 Visual Studio 无济于事.

One of them is just a Form, the other is a UserControl. None of them inherits from abstract classes or anything like that. Rebuilding or restarting Visual Studio does not help so far.

有修复它的想法吗?

推荐答案

最后,这里是设计师真正抱怨的地方:我直接从用户控件的 InitializeComponent() 调用了一个存储过程.虽然这确实可能不是一个好主意(单独的问题材料?),但我不得不说错误并没有以最好的方式呈现给我......

And finally, here is what the designer REALLY was complaining about: I had a call to a stored procedure right from the User Control's InitializeComponent(). While it may not be a good idea indeed (separate question material?), I have to say that the error was not presented to me in the best possible way...

这篇关于appSettings 配置部分中不存在密钥“UserID"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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