Visual Studio的表单设计器无法识别标签组件

时间:2016-05-05 12:49:42

标签: c++ winforms visual-studio-2015

我使用WinForms UI在C ++ / CLR中开发小型labwork项目。因此,当我在表单上添加任何标签时,表单设计器会显示以下错误:

 C++ CodeDOM parser error: Line: 185, Column: 17 --- Unknown type ''. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built.     

调用堆栈:

in Microsoft.VisualC.CppCodeParser.OnMethodPopulateStatements(Object sender, EventArgs e)
in System.CodeDom.CodeMemberMethod.get_Statements()
in System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
in System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
in Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
in System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)  

所有表单控件都有定义和初始化:

  //Definition
private: RichTextBox^  richTextBox1;
private: Button^  button1;
private: Button^  button2;
private: Button^  button3;
private: Button^  button4;
private: TextBox^  textBox1;
private: Button^  button5;
private: Button^  button6;
private: Button^  button7;
private: System::Windows::Forms::Label^  label1;

  //Initialisation
        this->richTextBox1 = (gcnew System::Windows::Forms::RichTextBox());
        this->button1 = (gcnew System::Windows::Forms::Button());
        this->button2 = (gcnew System::Windows::Forms::Button());
        this->button3 = (gcnew System::Windows::Forms::Button());
        this->button4 = (gcnew System::Windows::Forms::Button());
        this->textBox1 = (gcnew System::Windows::Forms::TextBox());
        this->button5 = (gcnew System::Windows::Forms::Button());
        this->button6 = (gcnew System::Windows::Forms::Button());
        this->button7 = (gcnew System::Windows::Forms::Button());
        this->label1 = (gcnew System::Windows::Forms::Label());

当我尝试更改定义中Label的命名空间时,表单设计器会向我显示另一个错误:

   C++ CodeDOM parser error: Line: 298, Column: 27 --- Member AutoSize not found in class System.Reflection.Emit.Label     

我可以看到,它不会将Label识别为System::Windows::Forms组件,因此无法呈现我的表单。在初始化和定义中使用命名空间的任何操作都没有帮助。最有趣的部分是项目编译成功。

那么,有没有办法解决它?

0 个答案:

没有答案