Adriaan W

Very strange thing...

I have made a program with a setup project. Last week the program setup files builds and installed without errors and the installed program worked.

Now I can run the program in Visual Studio, without errors; I can build the setup and I can run the setup without any problems. But when i tray to run the installed program, there is almost imediatly an Unhandled Exception error.

The error appears in the InitializeComponent of my main form. I tested it with some messageboxes.
MessageBox.Show("START PROG");
InitializeComponent();
MessageBox.Show("INIT COMP DONE");

the second messagebox is never shown. The program is also entering the InitializeComponent, I have also tested it with a messagebox.

then I searched the internet for a possible solution... I found following code to catch the exeption but this works half...

AppDomain currentDomain = AppDomain.CurrentDomain;

currentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledExceptions);


private static void UnhandledExceptions(object sender, UnhandledExceptionEventArgs args)
{
MessageBox.Show("start exception");
if (args == null)
{
MessageBox.Show("args is null");
}
else
{
MessageBox.Show(args.ToString());
if (args.ExceptionObject == null)
{
MessageBox.Show("exception object is null.");
}
else
{
MessageBox.Show(args.ExceptionObject.ToString());
}
}
}


the exception handlers show the first messagebox "start exception", but than crashes.

I have reinstalled the .Net framework 2.0 and repaired visual Studio.

WHAT TO DO


Re: Windows Forms General Application has generated an exception that could not be handled.

Chuck the Code Monkey

Try catching all exceptions to see what's actually happening and if you can trace it back(note that this is bad practice to leave in, but it can help when debugging):


MessageBox.Show("START PROG");
try
{
InitializeComponent();
}
catch(Exception ex)
{
MessageBox.Show(ex.ToString());
}
MessageBox.Show("INIT COMP DONE");






Re: Windows Forms General Application has generated an exception that could not be handled.

Adriaan W

I think its more computer related... i have installed the msi on my home computer .. works fine... and the program itself run also good.

No idea what problem I have on my office computer. But i will set the try catch block in the code to see if I can catch an exeption....




Re: Windows Forms General Application has generated an exception that could not be handled.

Adriaan W

Nope... the exception is never catched.. think because it is an unhandled exeption

Anyone an idea why the program works on my home computer and not on my develop computer It has worked all the time on the develop computer. Even if I use the setup file compiled on my home computer, the program will not run.

Very stupid problem




Re: Windows Forms General Application has generated an exception that could not be handled.

nobugz

We can only guess when you don't tell us the exception message and don't give us a stack trace. There is nothing special about InitializeComponent(), it just runs the code that the form designer generated. You can look at that code by clicking the Show All Files icon in Solution Explorer. Open the node that appears next to the form and double-click the Designer.cs file. You can single-step through it with a debugger to find out exactly what line causes the exception.





Re: Windows Forms General Application has generated an exception that could not be handled.

Adriaan W

Thats just the problem.. i have no stacktrace
the only thing i get is an unhandled exception error box and something with Threadx045 ...

AND the most strange is that is only not works on my develop pc after install but it works fine in Visual Studio.






Re: Windows Forms General Application has generated an exception that could not be handled.

nobugz

"something with Threadx045 ..." doesn't help. It might be Chinese to you but it could get us a long way towards a solution. Forced to make a guess: you might have forgotten to include a support assembly such as those generated by using ActiveX components. Compare the contents of the build directory with the install directory.





Re: Windows Forms General Application has generated an exception that could not be handled.

Adriaan W

.. but why my program works when i do "play" in Visual Studio

AND

works on my home computer

looks like unhandled exception are no fun