Vladimir Dimitrov wrote: > Hi, > > Or you can use something like this: > > try { > // This is needed in order for GTK# 2.12.8 to get the > proper theming > Assembly winForms = Assembly.Load > ("System.Windows.Forms, Version=2.0.0.0, Culture=neutral, > PublicKeyToken=b77a5c561934e089"); > Type appType = winForms.GetType > ("System.Windows.Forms.Application"); > MethodInfo method = appType.GetMethod > ("EnableVisualStyles", BindingFlags.Static | BindingFlags.Public); > method.Invoke (null, null); > > method = appType.GetMethod ("DoEvents", > BindingFlags.Static | BindingFlags.Public); > method.Invoke (null, null); > } catch { } > > I used that block before when the bug with the visual styles was not fixed, > to evade using references to SWF. > This is exactly the workaround as it is in Gtk# at the moment. We do not refernce Winforms directly, but load the assembly via reflection. The only problem is that we're missing the "try"-block.
This workaround is necessary to enable XP's visual styles with the default native Windows Gtk+ theme (in winforms apps, calling System.Windows.Forms.Application.EnableVisualStyles does this job for you). As I said, nobody has ever found out what DoEvents does and why produces the desired results. We'd really like to avoid loading SWF at runtime, but so far nobody has come up with a better solution :-) . This issue will be fixed in Gtk# 2.12.10, it's on my list and will be I'll get to it ASAP. I already added the try-block in my local copy, I'd just appreciate some feedback from Mike before I commit this. Christian > > > Andoni Morales wrote: > >> Hi, >> >> I have recently tried to upgrade from Mono 2.4 to 2.4.2.2 in Windows >> XP, which comes with gtk-sharp-2.12.9 >> >> My aplication does not depends on Winforms and using Mono 2.4 I can >> launch it without any problems. But when I use Mono 2.4.2.2 I run >> into this exception: >> >> Unhandled Exception: System.TypeInitializationException: An exception >> was thrown by the type initializer for Gtk.Application ---> >> System.IO.FileNotFoundException: Could not load file or assembly >> 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, >> PublicKeyToken=b77a5c561934e089' or one of its dependencies. The >> system cannot find the file specified. >> File name: 'System.Windows.Forms, Version=2.0.0.0, Culture=neutral, >> PublicKeyToken=b77a5c561934e089' >> >> Does that means that with gtk-sharp-2.12.9 I need System.Windows.Forms >> to run a Gtk app? >> _______________________________________________ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list