これはProgramクラスである:私は私のフォームを閉じるには、「X」ボタンをクリックするとC#のWinFormsアプリdoesntの近く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");
}
}
}
は今、これは私がして見るものです対
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).
2015しかし、それからの出力はまだdoesntのアプリケーションを終了し、プロセスはまだ「赤の広場」としてVisual Studioで開いているように見える通称ボタンがまだ押されるのを待っている「デバッグを停止」。私はそれを押したとき、私は、次のメッセージが出ます:
The program '[8216] TestClosingApp.vshost.exe' has exited with code -1 (0xffffffff).
を私は窓からのログオフを行い、問題が戻ってきた場合に興味深いことに消える、視覚的なスタジオを再起動すると、問題を解決していません。
これは 'COMException'を上げる問題ではありません。これにより、アプリケーションが終了しなくなる可能性があります。あなたはその例外の起源を共有できますか? –
は、フォームを閉じるコードを表示します –
[この質問](http://stackoverflow.com/questions/4281425/how-to-avoid-a-system-runtime-interopservices-comexception)を見てください - それは流すかもしれませんなぜあなたはCOMExceptionを取得しているのか、そしてその発見方法 – Cullub