[Gtk-sharp-list] GIO# System.InvalidCastException in VolumeMonitor.MountAdded event

Chris Szikszoy chris at szikszoy.com
Fri Oct 9 16:54:25 EDT 2009


I saw that GIO# bindings landed in the mainline gtk# branch recently and
wanted experiment to see if I could replace the old Gnome.VFS in my
application.  I've built the latest gtk# from svn and am running into a
problem with the VolumeMonitor.Mount* signals.  I keep getting an
InvalidCastException when trying to access args.Mount from any of the events
(MountAdded, MountRemoved, MountPreUnmount, MountChanged).

I've looked at the generated code and it seems to be failing at here:
public Mount Mount{
	get {
		return (GLib.Mount)GLib.SignalArgs.get_Args()[0];
	}
}

Try running this application to observe:
using System;
using GLib;
using Gtk;
namespace giotest
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			Gtk.Application.Init ();
			
			VolumeMonitor mon = VolumeMonitor.Default;

			mon.MountAdded += delegate(object o, MountAddedArgs a) {
				Console.WriteLine ("Mount Added: {0}", a.Mount.Name);
			};
			
			mon.MountRemoved += delegate(object o, MountRemovedArgs a) {
				Console.WriteLine ("Mount removed: {0}", a.Mount.Name);
			};
			
			Gtk.Application.Run ();
		}
	}
}

The relevant parts of the exception are:
Marshaling mount-added signal
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to
handle the exception.
System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. ---> System.InvalidCastException: Cannot cast
from source type to destination type.
  at GLib.MountAddedArgs.get_Mount () [0x00000] 
  at giotest.MainClass.<Main>m__0 (System.Object o, GLib.MountAddedArgs a)
[0x00000] in /home/chris/Projects/giotest/giotest/Main.cs:1 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke
(object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture) [0x00000] 
  --- End of inner exception stack trace ---

Should I file a bug?  I found the GTK# bugzilla at bugzilla.novell.com but I
wasn't sure if that was the right place.

Thanks in advance for all the help.
- Chris
-- 
View this message in context: http://www.nabble.com/GIO--System.InvalidCastException-in-VolumeMonitor.MountAdded-event-tp25815236p25815236.html
Sent from the Mono - Gtk# mailing list archive at Nabble.com.



More information about the Gtk-sharp-list mailing list