因此,我在Visual Studio 2012中創建了一個Windows32 C++ dll應用程序,然後在頭文件部分添加了一個窗體窗體並給它起名爲「UserInterface.h」。當我點擊添加按鈕時,我得到一個彈出窗口說:「你正在向本地項目添加一個CLR組件,你的項目將被轉換爲具有公共語言運行時支持,你想繼續嗎?我點擊是,它使文件「UserInterface1.cpp」和「UserInterface1.h」。C++錯誤:名稱後跟'::'必須是類或名稱空間名稱。 DLL中的WindowsForm
但在「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) {
}
};
}
我添加了註釋到錯誤彈出類似「錯誤:名稱後跟‘::’必須是類或命名空間名稱」有誰知道我爲什麼會遇到這些問題?
您是否添加了對您正在使用的項目的CLR組件的引用? –
我應該需要嗎?我會想,當我添加一個windowsform它不需要我添加引用爲它沒有錯誤 – connorbp