我是编程新手,我是一名机械工程师。谁能帮告诉我如何调试控制台应用程序如何在Windows中通过控制台应用程序创建(.exe)Visual C#2012
例如:
当我调试程序它提供了以下错误:(众议员是我的文件名)
Rep.exe doesn't contain a Static 'Main' Method suitable for an entry point
我是编程新手,我是一名机械工程师。谁能帮告诉我如何调试控制台应用程序如何在Windows中通过控制台应用程序创建(.exe)Visual C#2012
例如:
当我调试程序它提供了以下错误:(众议员是我的文件名)
Rep.exe doesn't contain a Static 'Main' Method suitable for an entry point
您需要在你的类中创建一个静态的Main方法。类似这样:http://msdn.microsoft.com/en-us/library/acy3edy3.aspx
显示您的代码。你的主应该有一个String []参数,是静态的,不返回任何东西。也许公开或内部(但我不确定这一点)。
事情是这样的:
class Program {
public static void Main(string[] args) {
//... your code....
}
}
如果从ConsoleApplication 来添加一个类调用Program
和它看起来像这样
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace YourNameSpace //<-------------------
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new YourForm()); //<----------------------
}
}
}
我认为这将解决您的问题:)
Yaser
谢谢你我知道了..............朋友 – user3415066
msdn中有一个"How to: Create a C# Console Application"。也许你应该从它开始。
你应该有这样的事情到你的代码:
using System;
public class Program
{
public static void Main() // dont forget the static
{
Console.WriteLine("hello world"); // just print "hello world"
Console.ReadLine(); // wait a key press before closing
}
}
的[程序不包含适合的切入点静态“主”方法]可能重复(http://stackoverflow.com/questions/ 10067063/program-does-not-contain-a-static-main-method-suitable-for-entry-point) –