Search code examples
winformsc++-clivisual-studio-2022program-entry-point

LINK2001,and LINK1120 errors visual studio 2022 CLR empty project


i am currently working on a web browser on visual studio 2022 and every time I execute the program these errors show up LINK2001 unresolved external symbol main and LINK1120 1 unresolved externals.

So what I thought was meant by 'external symbol' was the entry point we write at the begining of a program when we Select the Configuration Properties > Linker > Advanced property page and then we modify the Entry Point property I tried looking up other entry points other than main at so many websites and i wrote them but I didn't get results so i searched for tutorials but they are all in c# or visual basic or from a long time ago ( and still not in c++) I didn't find helpful answers so my question is what entry point should I write?


Solution

  • C++ CLR(.Net Framework) project needs a different main entry point.

    Cpp:

    #include "MyForm.h"//Winform header
    
    
    using namespace Project1;//winform namespace
    
    [STAThread]
    int main(array<System::String^>^ args)
    {
        Application::EnableVisualStyles();
        Application::SetCompatibleTextRenderingDefault(false);
        Project1::MyForm form;//Winform namespace
        Application::Run(% form);
        return  0;
    }