这是程序类:C#WinForms应用程序犯规接近达成Program.Main()结束时
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TestClosingApp
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Console.WriteLine("I AM AT THE END OF THE MAIN");
}
}
}
现在,当我点击“X”按钮关闭我的形式,这是我在看从2015年VS
I AM AT THE END OF THE MAIN
Exception thrown: 'System.Runtime.InteropServices.COMException' in System.Windows.Forms.dll
The thread 0x1c34 has exited with code 0 (0x0).
The thread 0x2008 has exited with code 0 (0x0).
但是,输出仍然不结束该应用程序,过程似乎仍是在Visual Studio中的“红方”开又名“停止调试”按钮仍然在等待被按下。当我按下它,我得到以下信息:
The program '[8216] TestClosingApp.vshost.exe' has exited with code -1 (0xffffffff).
有趣的是,如果我这样做从Windows注销,然后回来的问题消失,重新启动Visual Studio中没有解决的问题。
这不是提高'COMException'问题。这可能会导致应用程序无法关闭。你能分享那个例外的起源吗? –
显示你的代码,关闭表格 –
看看[这个问题](http://stackoverflow.com/questions/4281425/how-to-avoid-a-system-runtime-interopservices-comexception) - 它可能会脱落一些关于你为什么得到COMException的信息 - 以及如何找到它。 – Cullub