在主窗体的closing事件中,加入如下代码: if ( MessageBox.Show("要重新启动嘛?","提示", MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Question) == DialogResult.Yes) System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);

解决方案 »

  1.   

    采用VS.Net的默认的那种启动方式也许不太好判断是程序是否出错.就是Application.Run(),不好抓取其异常..使用VC的习惯. static void Main() 
    { try
    {
    throw new Exception("HI");
    using (CreateDevice frm = new CreateDevice())
    {
    if (!frm.InitializeGraphics()) // Initialize Direct3D
    {
    MessageBox.Show("Could not initialize Direct3D.  This tutorial will exit.");
    return;
    }
    frm.Show(); // While the form is still valid, render and process messages
    while(frm.Created)
    {
    frm.Render();
    Application.DoEvents();
    }
    }
    }
    catch
    {
    MessageBox.Show("重启啦");
    System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
    }
    }