Announcements

We are currently experiencing an issue impacting some Autodesk Products and Services - please refer to the Autodesk Health Dashboard for updates.

How can I add a static 'Main' method suitable for an entry point?

How can I add a static 'Main' method suitable for an entry point?

Iamhamidd
Observer Observer
854 Views
2 Replies
Message 1 of 3

How can I add a static 'Main' method suitable for an entry point?

Iamhamidd
Observer
Observer

I am getting an error on my code that says "Error CS5001
Program does not contain a static 'Main' method suitable for an entry point" I am coding in C# using Microsoft Visual Studio and .NET. This is my code. Link

    using System.IO;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
using System;






class projectsummer
{
    [CommandMethod("OpenDrawing", CommandFlags.Session)]
   

    public static void OpenDrawing()

    

    {
        string strFileName = "C:\\DRAFT.dwg";
        DocumentCollection acDocMgr = Application.DocumentManager;

        if (File.Exists(strFileName))
        {
            acDocMgr.Open(strFileName, false);
        }
        else
        {
            acDocMgr.MdiActiveDocument.Editor.WriteMessage("File " + strFileName +
                                                            " does not exist.");
        }
    }
}

I am not sure how to go about this error. Thank you!

0 Likes
855 Views
2 Replies
Replies (2)
Message 2 of 3

Kent1Cooper
Consultant
Consultant

[There is a >.NET-specific Forum< where you may find people better able to help you.]

Kent Cooper, AIA
0 Likes
Message 3 of 3

Ed__Jobe
Mentor
Mentor

While you wait for a moderator to move this, you should take a look at your project type. It looks like you may have created an exe project. Only exe's require a Main sub. Projects for use in AutoCAD need to be made from the template called "Class (.NET Framework)".

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature