日期:2014-05-20  浏览次数:20910 次

菜鸟菜问visual studio问题
建有一个解决方案,内有一个项目chatserver,在chatserver有两个窗体form1.cs和form2.cs,现在一启动调试,弹出form1窗体。
那如何使得在启动调试时,弹出的是form2窗体?
问题实在弱的很,却始终没能摸索出答案来,请各位前辈多指教。

------解决方案--------------------
在解决方案资源管理器里有一个Program.cs,双击进去把Main()里的Application.Run(new Form1());改一下就可以了
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
------解决方案--------------------
你的理解是对的,就是在 Main() 中改变成Form2就可以了.


[STAThread]

指示应用程序的 COM 线程模型是单线程单元 (STA)。

更多请参见MSDN:STAThreadAttribute 类
------解决方案--------------------
[STAThread] attribute指示应用程序的 COM 线程模式
------解决方案--------------------
标志入口函数是由STA线程启动的吧
我记得要启用CLR调试环境需要把入口函数改为MTA线程启动 就是改这个标签
------解决方案--------------------
static void Main()
{
Application.Run(new Form1());
}