picoe / Eto

Cross platform GUI framework for desktop and mobile applications in .NET
Other
3.61k stars 327 forks source link

[Gtk] 'Gtk.Window.set_AllowGrow' not found #881

Closed Jan-Ka closed 7 years ago

Jan-Ka commented 7 years ago

OS Ubuntu 17.04 Mono 4.6.2 Eto.Forms 2.3.0 GtkSharp 3.1.3 (? last updated 11/25/2015)

I get a really strange Exception when starting an Application using Eto.Forms / Eto.Platform.Gtk via mono on Ubuntu. The same Solution works on Windows 10 when built in Visual Studio 2017.

Unhandled Exception:
System.MissingMethodException: Method 'Gtk.Window.set_AllowGrow' not found.
  at Eto.GtkSharp.Platform+<>c.<AddTo>b__9_78 () [0x00000] in <54cd9927486a464cbf24a9914eaaac63>:0
  at Eto.Widget..ctor () [0x0006a] in <ba1cd6b5277e44a1a2ea07b34eff2c44>:0
  at Eto.Forms.BindableWidget..ctor () [0x00000] in <ba1cd6b5277e44a1a2ea07b34eff2c44>:0
  at Eto.Forms.Control..ctor () [0x00000] in <ba1cd6b5277e44a1a2ea07b34eff2c44>:0
  at Eto.Forms.Container..ctor () [0x00000] in <ba1cd6b5277e44a1a2ea07b34eff2c44>:0
  at Eto.Forms.Panel..ctor () [0x00000] in <ba1cd6b5277e44a1a2ea07b34eff2c44>:0
  at Eto.Forms.Window..ctor () [0x00000] in <ba1cd6b5277e44a1a2ea07b34eff2c44>:0
  at Eto.Forms.Form..ctor () [0x00000] in <ba1cd6b5277e44a1a2ea07b34eff2c44>:0
  at EtoFormsUI.MainWindow..ctor () [0x00000] in <10c65da0523747aeb903ffff1cccd0a8>:0
  at EtoFormsUI.EtoFormsUI.Main (System.String[] args) [0x0000b] in <10c65da0523747aeb903ffff1cccd0a8>:0
cwensley commented 7 years ago

Hi, thanks for the report. It looks like you're using the wrong Gtk assembly in Eto. You need Eto.Gtk3.dll (or the Eto.Platform.Gtk3 nuget) to use GtkSharp 3.x.

To use GtkSharp 2.x, you need to install gtk-sharp2 via apt in ubuntu. Otherwise, to use GtkSharp 3, install the gtk-sharp3 package. You shouldn't need to use any nuget packages for gtk-sharp itself.

Jan-Ka commented 7 years ago

Hi, thanks for the reply and your time.

TL;DR: On Ubuntu installing gtk-sharp3 and switching packages to Eto.Platform.Gtk3 made it run on Ubuntu. On Windows it now throws a System.DllNotFoundException looking for libgtk-3-0.dll.


I installed gtk-sharp2 and rebooted.

gtk-sharp2 is already the newest version (2.12.40-1).

I had to pin the Platform to Gtk2 since it wasn't able to Autodetect the current Platform on Windows as the Tutorials made it look like. This is the Content of the Main Class (namespace etc. removed for brevity):

[STAThread]
internal static void Main(string[] args)
{
    new Eto.Forms.Application(Eto.Platforms.Gtk2).Run(new MainWindow());
}

MainWindow is a Eto.Form and is exactly as in the Tutorials.

I just tried to remove the Platform parameter but it changed nothing. Since Gtk3 seems to be installed by default on Ubuntu I can switch to that but even with Gtk# installed (and rebooting afterwards) it does not seem to find the required dlls when running on Windows.

I guess I miss something simple - i do not want to package the dlls with my project if possible.

cwensley commented 7 years ago

@Jan-Ka you shouldn't have to specify anything in the Eto.Forms.Application constructor. If you do this it'll attempt to use that UI toolkit on every platform, which is not what you'd want. You want it to use WPF on windows, Gtk3 on linux, and Mac for macOS.

The auto detection should work for what you want to do, the logic is here for reference.

Basically, just make sure Eto.Gtk3.dll, Eto.Wpf.dll, Eto.dll, and your application assemblies are all in the same folder (and nothing else). It should then run on Linux using Gtk3 (if gtk-sharp3 is installed), and windows using WPF.

Hope this helps!

cwensley commented 7 years ago

Also, if you want to force a specific platform instead instead of using the built-in auto detection routines, you can roll your own like so:

E.g.

var platform = 
    EtoEnvironment.Platform.IsWindows ? Platforms.Wpf : 
    EtoEnvironment.Platform.IsUnix ? Platforms.Gtk3 : 
    EtoEnvironment.Platform.IsMac ? Platforms.Mac :
    null; 

new Application(platform).Run(new MainWindow());
Jan-Ka commented 7 years ago

Ok, it seems to work when adding

Eto.Forms
Eto.Platform.Windows
Eto.Platform.Gtk
Eto.Platform.Gtk3

then AutoDetection also seem to work. I got the wrong Idea from the readme/nuget text that Eto would choose from the available Platform Packages what it would render in.

I can now finally build and run on both Windows & Ubuntu. Thank you for your help and patience.