Visual Studio 2022 CLR 空项目 (.NET Framework) 入口点不起作用,即使在设置后也是如此

问题描述 投票:0回答:1

我正在尝试在 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 帖子。

任何帮助将不胜感激,并感谢大家的宝贵时间。如果您需要更多信息,请告诉我。

winforms c++-cli visual-studio-2022 clr program-entry-point
1个回答
0
投票

您修改的不是活动页面:

© www.soinside.com 2019 - 2024. All rights reserved.