[Gtk-sharp-list] Storing System.Type in a TreeStore

Gustavo Ramos eureko@grmexico.com.mx
Fri, 29 Aug 2003 03:51:15 -0500


I agree with you, but i will need to get the type information once for
building the tree, and other time when the user click on the tree view, to
present a type information. Another idea is: to store the Type in an array
when building the tree, and in the TreeStore the index. That way, I won't
need to reflect twice. Well, there are a lot of ways we can follow to reach
the goals, this isn't really a problem.

The important point that this problem exposes, is that some functionality of
GLib... Well, I'm about to post it in other message.

Cheers,

Gustavo, Mexico

> -----Mensaje original-----
> De: gtk-sharp-list-admin@lists.ximian.com
> [mailto:gtk-sharp-list-admin@lists.ximian.com]En nombre de Daniel Morgan
> Enviado el: Lunes, 25 de Agosto de 2003 11:42 a.m.
> Para: Gustavo Ramos; gtk-sharp-list
> Asunto: RE: [Gtk-sharp-list] Storing System.Type in a TreeStore
>
>
> How about storing a string name of the type.
>
> typeof(Type).ToString()
>
> -----Original Message-----
> From: gtk-sharp-list-admin@lists.ximian.com
> [mailto:gtk-sharp-list-admin@lists.ximian.com]On Behalf Of Gustavo Ramos
> Sent: Monday, August 25, 2003 6:23 AM
> To: gtk-sharp-list
> Subject: [Gtk-sharp-list] Storing System.Type in a TreeStore
>
>
> There is a NullReferenceException that I don't caught. I am
> suspecting about
> the System.Type I want to store in the TreeStore, it may not be
> supported...
> or is it? Am confused, any ideas?
>
> Regards, Gustavo
>
>
> treeStore = new Gtk.TreeStore(
> 	typeof(string),
> 	typeof(string),
> 	typeof(Type)
> );
> foreach(Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
> {
> 	Type asmType = asm.GetType();
>
> 	// Here is the error:
> 	TreeIter iterAsm = treeStore.AppendValues(
> 		asm.GetName().Name, asmType.FullName, asmType);
>
> 	foreach(Type t in asm.GetTypes())
> 	{
> 		TreeIter iterType = treeStore.AppendValues(
> 			iterAsm, t.Name, t.FullName, t.GetType());
> 		// some other processing
> 		// ...
> 	}
> }
>
> Error dump:
> Unhandled Exception: System.NullReferenceException: Object
> reference not set
> to
> an instance of an object.
>    at Gtk.TreeStore.gtk_tree_store_set_value(IntPtr raw, TreeIter& iter,
> Int32 c
> olumn, IntPtr value)
>    at Gtk.TreeStore.SetValue(TreeIter iter, Int32 column, Value value)
>    at Gtk.TreeStore._AppendValues(TreeIter iter, Array values)
>    at Gtk.TreeStore.AppendValues(Array values)
>    at Gtk.TreeStore.AppendValues(Object[] values)
>    at Grmexico.Samples.MainWindow.InitStore() in
> D:\Programacion\AlphaProjects\c
> sharp\mysqlnet-gtk\MainWindow.cs:line 49
>    at Grmexico.Samples.MySQLNetGtkApp.Main(String[] args) in
> D:\Programacion\Alp
> haProjects\csharp\mysqlnet-gtk\main.cs:line 13
>
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list
>
> _______________________________________________
> Gtk-sharp-list maillist  -  Gtk-sharp-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/gtk-sharp-list