Elec0
Elec0

Reputation: 2288

Program runs on Win 7, but not on Win 8

I have a program I've written on Windows 7 (64-bit) that compiles and runs correctly on my computer.

But on other computers (specifically on Windows 8 (64-bit)) the program does not run. When I try to run it it says that my program has stopped working, it crashes.

I should add, both computers have .Net installed at version 4.5.

But, if I delete all the components that I've added onto my form (I'm using Visual Studio 2012 Express) it runs just fine. But I have to delete all of the components. Deleting only some of them doesn't work.

Has anyone heard of this happening?

Upvotes: 2

Views: 1538

Answers (1)

Elec0
Elec0

Reputation: 2288

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);
    }

Upvotes: 5

Related Questions