Bug 460043

Summary: Vista-64: .Net Runtime Crash
Product: [Mono] gtk# Reporter: Jonathan Pobst <jpobst>
Component: gtk-sharpAssignee: Gtk# Bugs List <gtk-sharp-bugs>
Status: RESOLVED DUPLICATE QA Contact: Gtk# Bugs List <gtk-sharp-bugs>
Severity: Normal    
Priority: P5 - None    
Version: 2.x   
Target Milestone: ---   
Hardware: Other   
OS: Windows Vista   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: Test Case

Description Jonathan Pobst 2008-12-18 05:06:16 UTC
Created attachment 260730 [details]
Test Case

The attached program crashes the .Net runtime on Vista64 with the Gtk from:
gtk-sharp-runtime-2.12.7.msi


Unhandled Exception: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at Gtk.Application.gtk_main()
   at GtkTest.Program.Main(String[] args)

This works on XP-32bit.  I do not know if it is a Vista or a 64bit issue.
Comment 1 Mike Kestner 2008-12-18 05:44:20 UTC
Sounds like maybe a 64 bit issue.  The gtk+ binaries and the glue libraries in gtk-sharp are all 32 bit binaries.  This thread implies a possible solution:

http://social.msdn.microsoft.com/Forums/en-US/netfx64bit/thread/35b09f74-1d8e-4676-90e3-c73a439bf632/

"In your case, it's probably the first, so please make sure you compile your vb.net exe as 32 bit (X86) and NOT MSIL."

Whatever that means...

There was some effort made at a win64 installer on the mailing list. There are gtk+ binaries for win64 now. Even the gtk-sharp assemblies need to be built with a special flag to deal with the 32 bit long issue.  There was also an issue raised about needing to use utf8 specific filename apis in gtk file chooser on win64.

Bottom line, I think we've got significant work to provide a win64 installer and unfortunately, I don't even have a win64 machine to work with.  
Comment 2 Michael Hutchinson 2009-02-06 07:29:51 UTC
I can runs apps up to the point that it fails to find the native libs...

I believe the GTK# dlls should be compiled using csc with /platform:x86, so that 64-bit .NET CLR will not try to load them. The GAC supports having x86 and amd64 variants of the otherwise same-named dll side by side.
Comment 3 Michael Hutchinson 2009-02-06 07:32:25 UTC
This is with 2.12.8, implying the image error may have been fixed.

The error I get is:

System.DllNotFoundException: Unable to load DLL 'libgtk-win32-2.0-0.dll': The sp
ecified procedure could not be found. (Exception from HRESULT: 0x8007007F)
   at Gtk.Application.gtk_init(Int32& argc, IntPtr& argv)
   at Gtk.Application.Init()
   at MonoDevelop.Ide.Gui.IdeStartup.Run(String[] args) in C:\Documents and Sett
ings\Administrator\Desktop\monodevelop\main\src\core\MonoDevelop.Ide\MonoDevelop
.Ide.Gui\IdeStartup.cs:line 74
   at MonoDevelop.Startup.SharpDevelopMain.Main(String[] args) in C:\Documents a
nd Settings\Administrator\Desktop\monodevelop\main\src\core\MonoDevelop.Startup\
MonoDevelop.Startup\MonoDevelopMain.cs:line 21
Comment 4 Michael Hutchinson 2009-02-06 08:00:33 UTC
Apparently Corflags.exe can be used to tweak this flag on the binaries:

http://www.request-response.com/blog/PermaLink,guid,cf345d71-cdc7-46b9-8c1c-eb21581a9222.aspx

So, I did this to MonoDevelop.exe, and got it running in 32-bit mode, but it still can't find the libraries. This means the GTK# installer is broken on 64-bit, even for 32-bit apps.
Comment 5 Michael Hutchinson 2009-02-06 08:07:41 UTC
Actually, my bad, that was the Medsphere GTK# 2.10 interfering. Removed that and I can now run MD on 32-bit .NET on Vista 64.
Comment 6 Mike Kestner 2009-04-27 03:05:41 UTC
Dupping.

*** This bug has been marked as a duplicate of bug 473566 ***