积极答复者
程序main函数未执行

问题
答案
全部回复
-
你好,
是不是你的程序隐藏了界面。 可以分享一下可以重现你问题的代码吗? 另外你可以试一下Debug, 看看是那行代码出的问题。
Best regards,
Zhanglong
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com. -
不是每次运行程序都出现这个问题,偶然性比较强。调试环境下没出现过。
我刚重新看了下转储文件的运行栈,是停留在Application.Run(new UserForm())后的UserForm构造函数中。相关代码片段如下:
Main()中代码:
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);bool createNew = false;
EventWaitHandle programStarted = new EventWaitHandle(false, EventResetMode.AutoReset, "EventHandle", out createNew);
// 如果该命名事件已经存在(存在有前一个运行实例),则发事件通知并退出
if (!createNew)
{
programStarted.Set();
return;
}
Environment.SetEnvironmentVariable("WEBKIT_IGNORE_SSL_ERRORS", "1");//添加此行代码以允许webkitbrowser支持https网站的访问
Application.Run(new MainForm(programStarted));
MainForm构造函数代码:
MainForm : CCSkinMain
public MainForm(EventWaitHandle programStratedEvent)
{
InitializeComponent();......
}
-
你好,
如果不是每次都有这种情况,我建议你我Main()函数中增加写日志的功能(可以考虑Log4net), 并加上Try Catch 在你的Main 函数中,看看能不能收集到有用的信息。
Best regards,
Zhanglong
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.