Visual Studio 2022 CLR Empty Project (.NET Framework) entry point is not working, even after being set

70 Views Asked by At

I am trying to run a Windows Form in Microsoft Visual Studio 2022. When I attempt to run the solution I get the following error: "LNK1561 entry point must be defined", which links to this page.

I have followed every step of this tutorial, and have added the entry point to the linker via Project properties (shown in the screenshots below), but the error persists.

Screenshots: compiler with error

project properties subsystem

project properties entry point

Here is the code for 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);
}

and 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
    };
}

I am new to Visual Studio so I'm not sure where to go from here, I have tried changing the entry point name in both the code and Project Properties, but from my understanding this should be working.

I cannot find a stackoverflow post that contains the same issue.

Any help would be greatly appreciated, and thank you all for your time. Please let me know if you need any more information.

1

There are 1 best solutions below

0
Minxin Yu - MSFT On BEST ANSWER

What you modified is not active page:

enter image description here

enter image description here