[Mono-dev] Gtk depends on Winforms ¿?
Vladimir Dimitrov
vlad.dimitrov at gmail.com
Sun Sep 6 03:57:01 EDT 2009
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.
- Vlad
-----Original Message-----
From: mono-devel-list-bounces at lists.ximian.com
[mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of Christian
Hoff
Sent: Saturday, September 05, 2009 10:16 AM
To: Andoni Morales
Cc: mono-devel-list at lists.ximian.com
Subject: Re: [Mono-dev] Gtk depends on Winforms ¿?
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
> In Windows I use 'mkbundle' [1] to generate from my c# app an
> executable file that can be launched on a computer that doesn't not
> have mono installed. mkbundle builds a new executable that embeds all
> the assemblies needed by the c# executable to run.(I attach the
> output)
> 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? Why does Gtk.Application has a runtime dependency on
> System.Windows.Forms and why mkbundle is not even aware of this
> dependency and does not include this assembly in the bundle?
> It also happens with 2.4.2.3 so I believe it's a gtk-sharp issue
>
You're right. gtk-sharp has a Winforms dependency on the Windows
platform to enable visual styles by calling
System.Windows.Forms.Application.DoEvents via reflection. Nobody has
ever found out why this works or how we could implement such
functionality without loading winforms.
We should probably put that code in a try-block. What do you think, Mike?
Christian
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list
More information about the Mono-devel-list
mailing list