1

I'm trying to get my linux Gtk# application working on Windows. When I try to run it, I get this error message:

Unhandled Exception: GLib.GException: Unhandled tag: 'requires'

at Gtk.Builder.AddFromFile(String filename)

at Interface.MainWindow..ctor()

at [My Project Name].MainClass.Main(String[] args) in c:\Path\To\Main.cs:line 10

It seems to be happening when trying to build the interface from my Glade file. I've checked and the path to the glade file is correct. What might be going wrong?

Here is some code to reproduce the problem:

using System;
using Gtk;

namespace TestGtk {
    class MainClass {
        public static void Main (string[] args)
        {
            Application.Init();

            string gladefile = @"C:\path\to\gladefile.glade";
            Builder builder = new Builder();
            builder.AddFromFile(gladefile);

            Application.Run();
        }
    }
}

4 Answers 4

1

Strange... I don't know why on windows GTK# does not support requires. Anyway I'd try to remove the <requires ... /> tag from gladefile.glade.

Sign up to request clarification or add additional context in comments.

1 Comment

This didn't seem to help. I ended up just replacing my glade files with native code, which solved my cross-platform issues.
0

This most likely means that your Glade file is corrupt or has got some weirdness in it.

Comments

0

You're using GtkBuilder to load GladeXML files. GtkBuilder has different XML format, incompatible with GladeXML (it more generic). If you use glade-3 to design your UI, you have an option to save as GtkBuilder XML or GladeXML. Also, glade has utility called gtk-builder-convert that you can use to convert GladeXML to GtkBuilder XML.

So, there are two options:

  1. Use glade-3 and save your UI in GtkBuilder format
  2. Use gtk-builder-convert utility

1 Comment

They are in GtkBuilder format. They were saved in GtkBuilder format on linux, and this code works on linux.
0

Glade is for GTK 3.x and your system is probably on GTK 4.x.

I had a similar issue when the version was not specified in a Python app using a .glade file, and upon running it would show:

Use gi.require_version('Gtk', '4.0') before import to ensure that the right version gets loaded.

It worked prior to an Ubuntu update last I ran if. After adding

import gi
gi.require_version("Gtk", "3.0")

It works.

A similar issue was noted in a Haskell app. I am not sure how one changes the reference to GTK3 on C#.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.