开发者

What does "Unhandled Exception: GLib.GException: Unhandled tag: 'requires'" mean?

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();
        }
    }
}


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.


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


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


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#.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜