So i made a windows32 C++ dll application in visual studio 2012 and then i added a windows form in the header files section and gave it the name "UserInterface.h". When i clicked the Add button i got a popup saying "You are adding a CLR component to a native project. Your project will be converted to have Common Language Runtime support. Do you wish to continue?" and i clicked yes and it made the files "UserInterface1.cpp" and "UserInterface1.h".
but in the "UserInterface1.h" there are errors all over. here are its contents:
#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) {
}
};
}
I added comments to where the errors pop up like "Error: name followed by '::' must be a class or namespace name." does anyone know why i am getting these problems?
You will need to create a mixed mode application. Microsoft has clear instructions for the required steps.
The MS instructions will resolve the problem for System and System::Collections, but does not resolve the issues for System::ComponentModel, System::Windows::Forms, System::Data, and System::Drawing.
To compile, you must add references for the missing DLLs to the application. You can remove the
using <System.Windows.Forms>
from the stdafx.h file. Right-click properties and selectReferences...
, then selectAdd New Reference
, then check the following DLLsThe code will now compile.