c# - 不包含适合入口点的静态 'main' 方法

标签 c# visual-studio-2010

我现在开始将我的代码组织到单独的 .cs 文件中,为了让与 UI 一起工作的方法继续这样做,我将在相同的命名空间和公共(public)部分类名下创建 .cs 代码,这样这些方法可以互操作。

我的标题在四个文件中看起来像这样,包括我调用的主要核心文件:

public shell()
{
InitializeComponent(); 
}

与 UI 一起工作的 .cs 文件的标题区域(并且似乎导致了这个新的冲突):

using System;
using System.Windows.Forms;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.IO;
using System.Data.SqlServerCe;
using System.Diagnostics;
using System.Threading;
using System.Collections.Specialized;
using System.Net;
using System.Runtime.InteropServices;
using watin = WatiN.Core;
using WatiN.Core.Native.InternetExplorer;
using System.Web; 


namespace WindowsFormsApplication1
{

    public partial class shell : Form
    {

现在,当我尝试调试/预览我的应用程序时(顺便说一句,这是 Visual Studio 2010 Express 中的 Windows 应用程序)我收到此错误消息:

Does not contain a static 'main' method suitable for an entry point

我查看了 Application->Startup 对象中的应用程序属性,但它没有提供任何选项。我如何通知应用程序从具有我的 InitializeComponent(); 的 .cs 文件开始?命令?

  • 到目前为止,我环顾四周都没有找到解决方案。
  • 每个 .cs 文件的属性都设置为“编译”。
  • 我在解决方案资源管理器中没有看到 App.xaml 文件,但看到了 app.config 文件。

我还是个新手,这是我第一次尝试使用 C# 代码组织方法。

最佳答案

我也在研究这个问题,就我而言,解决方案太简单了。我在解决方案中添加了一个新的空项目。新添加的项目会自动设置为控制台应用程序。但由于添加的项目是一个“空”项目,因此该新项目中不存在 Program.cs。 (如预期的那样)

我需要做的就是将项目属性的输出类型更改为类库

关于c# - 不包含适合入口点的静态 'main' 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9607702/

相关文章:

c# - Visual Studio 2010 线程窗口中的 <Not Available> 和 [Thread Destroyed] 详细信息

c# - 迁移未开始 - Autofac 抛出异常

c# - 当内容具有 Conditional 属性时,C# 编译器是否优化 foreach block ?

c# - Asp.net mvc3、C#、Datetime.Parse()

c# - .NET 错误处理 : try/catch VS event VS return-value/status-fields

c# - 带有 Framework 2.0 的 Visual Studio 2010 命令行

c# - 修改machine.config后VS崩溃,组件也多

c# - 如何为 CRM 2011 插件正确设置 C# 单元测试?

c# - 自定义XML序列化,如何编写自定义根元素?

c++ - 无法找到或打开 PDB 文件消息,pdb 存在