所以我在visual studio 2012中制作了一个windows32 C++ dll应用程序,然后我在头文件部分添加了一个windows窗体并将其命名为“UserInterface.h”。当我单击“添加”按钮时,我收到一个弹出窗口,提示“您正在将 CLR 组件添加到本机项目。您的项目将被转换为具有公共语言运行时支持。您希望继续吗?” 我点击是,它生成了文件“UserInterface1.cpp”和“UserInterface1.h”。
但是在“UserInterface1.h”中到处都是错误。以下是它的内容:
#pragma once
namespace AssultCubeDLL {
//ERRORS HERE: ******************************************************
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 UserInterface
/// </summary>
// ERROS HERE: *********************************************************
public ref class UserInterface : public System::Windows::Forms::Form
{
public:
UserInterface(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~UserInterface()
{
if (components)
{
delete components;
}
}
private:
/// <summary>
/// Required designer variable.
/// </summary>
// ERRORS HERE: ************************************************
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->SuspendLayout();
//
// UserInterface
// ERRORS HERE: *******************************************************
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 262);
this->Name = L"UserInterface";
this->Text = L"UserInterface";
this->Load += gcnew System::EventHandler(this, &UserInterface::UserInterface_Load);
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void UserInterface_Load(System::Object^ sender, System::EventArgs^ e) {
}
};
}
我在弹出错误的地方添加了注释,例如“错误:名称后跟'::'必须是类或命名空间名称。” 有谁知道我为什么会遇到这些问题?