xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.64k stars 1.88k forks source link

[Bug] Not compiling code from Microsoft documentation (GTK) #15761

Closed KirMozor closed 1 year ago

KirMozor commented 1 year ago

Description

I'm trying to make my program in GTK using Xamarin, but I've already started having problems, nothing works (I used this tutorial: https://learn.microsoft.com/en-us/xamarin/xamarin-forms/platform/other/gtk?tabs=windows).

Steps to play

  1. Open JetBrains Rider
  2. Create a new .NET Core project, class library type
  3. Rename the Class1.cs file to Program.cs
  4. Install 2 packages into the project. Xamarin.Forms (5.0.0.2578) and Xamarin.Forms.Platform.GTK (5.0.0.2578).
  5. Insert the following code:
    
    using Xamarin.Forms;
    using Xamarin.Forms.Platform.GTK;

namespace Example.GTK { class MainClass { [STAThread] public static void Main(string[] args) { Gtk.Application.Init(); Forms.Init(); var app = new App(); var window = new FormsWindow(); window.LoadApplication(app); window.SetApplicationTitle("Game of Life"); window.Show(); Gtk.Application.Run(); } } }


### Expected behaviour.
Everything will start up and the window from the manual will appear.

### Actual behaviour
Build errors

### Basic information

- Version with issue: 5.0.0.2578
- Last known good version: ?
- Platform Target frameworks: <!-- All that apply -->
  - GTK: 5.0.0.2578
- NuGet packages: Xamarin.Forms (5.0.0.2578), Xamarin.Forms.Platform.GTK (5.0.0.2578)
- Affected devices: ?

### Environment

user@KirMozorPC

OS: Arch Linux x86_64 Kernel: 6.3.6-arch1-1 Uptime: 1 hour, 34 mins Packages: 1032 (pacman) Shell: fish 3.6.1 Resolution: 1920x1080 DE: GNOME 44.2 WM: Mutter WM Theme: Adwaita Theme: Dracula [GTK2/3] Icons: Dracula [GTK2/3] Terminal: alacrity CPU: Intel i5-2500S (4) @ 3.700GHz GPU: NVIDIA GeForce GT 730 Memory: 6169MiB / 7905MiB



</details>

### Build logs

https://pastebin.com/gSDSBi2f
jfversluis commented 1 year ago

Looks like you might have not added (the right version of) the GTK libraries. Unfortunately the GTK backend is not officially supported by Microsoft and I know very little about it. I hope you can get it fixed!