当我尝试单击设计器选项卡以获取设计器 View 时,出现此错误:
To prevent possible data loss before loading the designer, the following errors must be resolved:
The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: Form1 --- The base class 'System.Windows.Forms.Form' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.
我想进入设计师,但不知道出了什么问题。我的 Form1 代码在顶部如下所示:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using System.Diagnostics;
namespace foobar
{
public partial class Form1 : Form
{
List<CharLabel> allChars = new List<CharLabel>();
public Form1()
{
... etc ...
有什么想法吗?
最佳答案
当您直接从代码编辑器更改分部类(如表单)内的命名空间或其他项目时,您正在邀请疯狂。顾名思义,分部类是在代码 View 上“部分”定义的类,但还有另一部分由 VS 自动生成,即该类的另一部分。在该部分中,它包含所有 UI 元素、字体、默认值等的定义。当您更改类的一部分中的 namespace 时,另一部分不知道要做什么,然后就会出现有趣的错误。当更改命名空间、类名、事件方法名时,始终使用 VS 中的 Refactor 选项。
在你的情况下,我可能会回到它的旧名称,然后使用VS提供的重构选项(突出显示组件名称,Ricgh单击,重构->重命名)
希望这有帮助。
关于c# - 由于奇怪的错误,无法在 Visual Studio 2008 C# Windows 窗体中看到设计器 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1180891/