我正在尝试在 Microsoft Visual Studio 2022 中运行 Windows 窗体。当我尝试运行该解决方案时,出现以下错误:“必须定义 LNK1561 入口点”,该错误链接到 此页面。
我已遵循本教程的每一步,并通过项目属性将入口点添加到链接器(如下面的屏幕截图所示),但错误仍然存在。
这是MainForm.cpp的代码:
#include "MainForm.h"
using namespace System;
using namespace System::Windows::Forms;
void main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
EyeDropperUI::MainForm form;
Application::Run(% form);
}
和MainForm.h:
#pragma once
namespace EyeDropperUI {
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 MainForm
/// </summary>
public ref class MainForm : public System::Windows::Forms::Form
{
public:
MainForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MainForm()
{
if (components)
{
delete components;
}
}
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->components = gcnew System::ComponentModel::Container();
this->Size = System::Drawing::Size(300,300);
this->Text = L"MainForm";
this->Padding = System::Windows::Forms::Padding(0);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
}
#pragma endregion
};
}
我是 Visual Studio 新手,所以我不确定从这里开始哪里,我尝试更改代码和项目属性中的入口点名称,但根据我的理解,这应该有效。
我找不到包含相同问题的 stackoverflow 帖子。
任何帮助将不胜感激,并感谢大家的宝贵时间。如果您需要更多信息,请告诉我。