Program runs on Win 7, but not on Win 8

為{幸葍}努か 提交于 2019-12-06 06:09:09

Thanks to Hans, I hadn't heard of the AppDomain.CurrentDomain.Unhandled exception before.

My actual problem was that I didn't have the VisualBasic things installed on the Windows 8 computer, and I was trying to use them. Removing the references of that from my program fixed the program.

The actual code I used to find the problem (In Program.cs):

static void Main()
    {
        AppDomain currentDomain = AppDomain.CurrentDomain;
        currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler);
     (...)   
    }
static void MyHandler(object sender, UnhandledExceptionEventArgs args)
    {
        Exception e = (Exception)args.ExceptionObject;
        Console.WriteLine("MyHandler caught : " + e.Message);
        Console.WriteLine("Runtime terminating: {0}", args.IsTerminating);
        MessageBox.Show("Handler caught: " + e.Message + "\nRuntime terminating: " + args.IsTerminating);
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!