My answer contains two parts. The first part shows how to find a problem when your program crashes before it starts. The second part explains the fix that solves the problem.
Part 1 - Why did my program crash?
It is strange that my program worked on other computers and other versions of Windows. The program did not work on computers running Windows 7 (and, apparently, 64-bit). So my first instinct was to look at the differences between older versions of Windows and newer versions. However, much seems to have changed, so this is a lost cause.
My second attempt to find the problem used by WinDbg is a debugger that allows you to see where your program crashed. The problem with this attempt was that stacktrace did not point to information that helped me understand the problem. At first he pointed me in the wrong direction. I made me look at the signing of my meeting. However, this was not part of my problem.
The third attempt made me look at which exception was thrown from within the program. I did this by adding a little registration code and an unexpected exception handler.
In the main method, I added this code:
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler (CurrentDomain_UnhandledException); TraceListener log = new TextWriterTraceListener ("abacus.log"); Trace.Listeners.Add (log); Trace.Listeners.Add (new ConsoleTraceListener ());
An exception handler is called whenever an exception is thrown. Trace statements initialize various logging handlers. Add /d:TRACE to enable diagnostics. In the class, I added this method, which prints the information contained in the exception.
static void CurrentDomain_UnhandledException (object sender, UnhandledExceptionEventArgs e) { try { Exception ex = (Exception)e.ExceptionObject; Trace.Write ("Whoops! Please contact the developers with the following information:\n\n" + ex.Message + ex.StackTrace + ex.InnerException.Message + ex.InnerException.StackTrace); Trace.Flush (); } finally { Application.Quit(); } }
The launch of this extended program resulted in a log message with exception information. In this journal post, I found a post explaining why my program crashes. I am trying to download a 64-bit version of assemblies that are not available as 64-bit, only 32-bit. And this is the problem.
Part 2 - How to stop your program from crashes?
In my first attempt, I changed the parameter in MonoDevelop, which forces it to generate 32-bit code. This did not solve my problem.
In the second attempt, I downloaded a program called corflags.exe , which is included in the Windows SDK. This program allows me to change the flag that causes Windows to run this program as a 32-bit program. This solves my problem.
corflags.exe /32BIT+ program