我今天开始将代码组织到单独的 .cs 文件中,为了允许与 UI 一起使用的方法继续这样做,我将在相同的命名空间和公共部分类名下创建 .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 应用程序)时,我收到以下错误消息:
不包含适合入口点的静态“main”方法
我查看了应用程序->启动对象中的应用程序属性,但它没有为我提供任何选项。如何通知应用程序从包含 InitializeComponent(); 的 .cs 文件开始?命令?
- 到目前为止我已经环顾四周没有解决方案。
- 每个 .cs 文件的属性都设置为“编译”。
- 我在解决方案资源管理器中没有看到 App.xaml 文件,但确实看到了 app.config 文件。
我还是个新手,这是我第一次尝试使用 C# 代码组织方法。
我也在研究这个问题,就我而言,解决方案太简单了。我向解决方案添加了一个新的空项目。新添加的项目会自动设置为console application
。但由于添加的项目是一个“空”项目,所以没有Program.cs
存在于那个新项目中。 (如预期)
我所需要做的就是改变output
项目属性的类型Class library
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)