tags:

views:

171

answers:

3

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

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

Paul Betts
+1  A: 

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
dmitry_vk
They are in GtkBuilder format. They were saved in GtkBuilder format on linux, and this code works on linux.
Matthew
+1  A: 

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.

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