C++ Visual Studio 2015 CLR Windows 窗体命名空间错误
C++ Visual Studio 2015 CLR Windows Form Namespace error
嗨,我正在尝试创建一个函数,该函数想要为使用 Windows 表单向导创建的表单获取类。Visual Studio 正在使用项目名称作为窗体类"NewCustomerForm"的命名空间,但是当我尝试使用该类作为参数创建一个函数时,它说当我编译代码时,我收到以下错误消息:
Error C2871 'Project1': a namespace with this name does not exist
这是它NewCustomerTab.h
抱怨的文件:
#ifndef __NewCustomerTab_H__
#define __NewCustomerTab_H__
#include "NewCustomerForm.h"
using namespace Project1;
ref class CNewCustomerTab :
public System::Windows::Forms::TabPage{
public:
CNewCustomerTab(NewCustomerForm^);
private:
System::Windows::Forms::Form^ form1;
};
这是表单类NewCustomerForm.h
:
#pragma once
#include "NewCustomerTab.h"
namespace Project1 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for NewCustomerForm
/// </summary>
public ref class NewCustomerForm : public Form
{
public:
NewCustomerForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~NewCustomerForm()
{
if (components)
{
delete components;
}
}
public: System::Windows::Forms::Panel^ panel1;
private: System::Windows::Forms::Label^ label1;
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->panel1 = (gcnew System::Windows::Forms::Panel());
this->label1 = (gcnew System::Windows::Forms::Label());
this->panel1->SuspendLayout();
this->SuspendLayout();
//
// panel1
//
this->panel1->Controls->Add(this->label1);
this->panel1->Dock = System::Windows::Forms::DockStyle::Fill;
this->panel1->Location = System::Drawing::Point(0, 0);
this->panel1->Name = L"panel1";
this->panel1->Size = System::Drawing::Size(842, 563);
this->panel1->TabIndex = 0;
//
// label1
//
this->label1->AutoSize = true;
this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 24, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->label1->Location = System::Drawing::Point(251, 31);
this->label1->Name = L"label1";
this->label1->Size = System::Drawing::Size(229, 37);
this->label1->TabIndex = 0;
this->label1->Text = L"New Customer";
//
// NewCustomerForm
//
//this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
//this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(842, 563);
this->Controls->Add(this->panel1);
this->Name = L"NewCustomerForm";
this->Text = L"NewCustomerForm";
this->panel1->ResumeLayout(false);
this->panel1->PerformLayout();
this->ResumeLayout(false);
}
#pragma endregion
};
}
我做错了什么,我包含 Form 类文件,它说Project1
是一个命名空间。
必须使用公共语言运行时支持 (/clr) 进行编译。单击解决方案,在"配置属性"中选择"常规",然后为"公共语言运行时支持"选择"clr"。
相关文章:
- 命名空间中具有.h和.cpp文件的类
- 从父命名空间重载类型
- 在命名空间中定义函数还是限定函数
- C++:对不存在的命名空间使用命名空间指令
- 通过继承类使用来自不同命名空间的运算符
- 使用命名空间时出现多个定义错误
- CUDA内核和数学函数的显式命名空间
- 嵌套的匿名命名空间
- CMakeLists.txt中的命名空间表示法
- 类是C++中的命名空间吗
- 在命名空间中使用全局命名空间中的函数
- 如何使 std::sort 在 std::swap 和我的命名空间的模板化交换之间没有名称冲突?
- '使用命名空间{嵌套在另一个命名空间中的某个命名空间}"
- 是否可以将函数导入命名空间,但不能导出它?
- C++ C++类中的命名空间降级
- 如何使用 soong 命名空间来有条件地编译模块
- 使用 Clang++ 有没有办法将文件作为命名空间等包含?
- 使用 make 编译 MPI,几个命名空间错误,例如"错误:未知类型名称'使用'?
- 如何通过命名空间调用非静态方法
- C++ Visual Studio 2015 CLR Windows 窗体命名空间错误