“Compile with /main to specify the type that contains the entry point.”

前端 未结 4 746
不思量自难忘°
不思量自难忘° 2021-02-08 06:20

Per the code below, I am getting the following message. I am fairly certain \"why\" I am getting it, I just don\'t know how to rearrange the code to move/remove/replace one of t

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-08 07:12

    None of the answers get straight to the point.

    The properties Dialog of the project, accessed by right-clicking the project, has an Application tab. On this tab there is a drop down list for 'Startup Object' -- just select the correct class file that Visual Studio should target. As long as there is a Main static void event in that class file, it will target it. Be sure Main is capitalized. This won't work:

    static void main(string[] args) { ... code ... }

    Here is an image:

    In a web project you can right click on an ASPX file and set it as the startup page, very similar thing. Why Visual Studio buries this setting doesn't make sense but this is how you do it.

提交回复
热议问题