What has changed between Windows XP and 7 that caused my Mono C # application to crash?

I created and compiled a C # application using the Mono environment on Linux. The program works in Windows XP and Linux. However, the moment I run it on Windows 7, it crashes without any useful information.

What has changed between these two versions of Windows, what can do this?

Source code is available at http://github.com/pstuifzand/Abacus/ .

Update

When I run the code under WinDBG, I get the following stack trace.

Child-SP RetAddr Call Site 00000000`0016de80 000007fe`f465ffb3 KERNELBASE!RaiseException+0x3d 00000000`0016df50 000007fe`f49b7477 mscorwks!StrongNameFreeBuffer+0x51a3 00000000`0016e040 000007fe`f49b9656 mscorwks!Ordinal24+0xb957 00000000`0016e070 000007fe`f4a3c525 mscorwks!Ordinal24+0xdb36 00000000`0016e0a0 000007fe`f4a3c53b mscorwks!StrongNameSignatureVerificationEx+0x2fb5 00000000`0016e110 000007fe`f4611a2a mscorwks!StrongNameSignatureVerificationEx+0x2fcb 00000000`0016e140 000007fe`f4a96b38 mscorwks!StrongNameTokenFromPublicKey+0x744fa 00000000`0016ebc0 000007fe`f4a821f2 mscorwks!PreBindAssembly+0x24978 00000000`0016ec00 000007fe`f461795a mscorwks!PreBindAssembly+0x10032 00000000`0016ecf0 000007fe`f47114f7 mscorwks!StrongNameTokenFromPublicKey+0x7a42a 00000000`0016edb0 000007ff`001f012a mscorwks!IEE+0xd8fb 00000000`0016ee80 000007fe`f4711612 0x7ff`001f012a 00000000`0016eeb0 000007fe`f463ee13 mscorwks!IEE+0xda16 00000000`0016ef00 000007fe`f4aebc51 mscorwks!CreateAssemblyNameObject+0x5cbb 00000000`0016efa0 000007fe`f4567dc7 mscorwks!PreBindAssembly+0x79a91 00000000`0016f1e0 000007fe`f4544118 mscorwks!GetCLRFunction+0xccaf 00000000`0016f440 000007fe`f4bd7e3d mscorwks+0xf4118 00000000`0016f730 000007fe`f453651b mscorwks!GetAssemblyIdentityFromFile+0x195bd 00000000`0016fd00 000007fe`f4553e60 mscorwks+0xe651b *** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscoreei.dll - 00000000`0016fd50 000007fe`f65a3309 mscorwks!CorExeMain+0xac 
+4
source share
1 answer

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 
+8
source

Source: https://habr.com/ru/post/1341432/


All Articles