且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

窗体设计器已无法在Visual Studio中使用窗体

更新时间:2023-12-06 08:08:04

我不小心将自己锁定了,在锁定后写了错误消息

I accidentally locked myself out, with error message written behind the locked door.

问题:在工作期间,我暂时将一个简单的帮助程序类添加到了表单代码文件的开头。 如果那段时间我让设计师打开了,我可能会看到以下错误:

Issue: During the work, I temporarily added a trivial helper class to the beginning of the form code file. If I had the designer open that time, I could have seen the following error:


Form1类可以被设计,但不是文件中的头等舱。 Visual Studio要求设计人员使用文件中的第一类。移动类代码,使其成为文件中的第一类,然后尝试再次加载设计器。

The class Form1 can be designed, but is not the first class in the file. Visual Studio requires that designers use the first class in the file. Move the class code so that it is the first class in the file and try loading the designer again.

要注意的是, 该错误仅在设计器中显示。如果您现在仅打开代码窗口,则不会发现错误-更糟的是,您将不再被允许进入设计器视图来发现它。

The catch is, the error shows only in the designer. If you have only code window open at the moment, you won't spot the error – and worse, you are no more allowed to enter the designer view to discover it.

因此,在Visual Studio不提供任何线索的情况下可能会发生–唯一的帮助就是合格的猜测和试用。

So a case can happen, when Visual Studio gives no clue – the only help is qualified guess and trial.