public void OnCombobox1Changed (object sender, EventArgs e)
{
handler.name = combobox1.ActiveText;
}
The code sample is a handler (auto generated by gtk# using Mono's gui developer) with my own variable assignment in it. I have three classes, a win class that contains my gui components, which the sample is from, a database handler class, and my main class. handler is already instantiated in main and works with no problems, I can successfully populate comobox1 from my database using handler. I can put a simple Console.Writeline(combobox1.ActiveText); in the signal handler above instead of what's there and it works perfectly.I cannot figure out why this variable assignment doesnt work, handler.name is a class level string variable and combobox1.ActiveText is a string as well, so variable type isn't the problem. when I run this with the above code instead of the Console.Writeline(combobox1.ActiveText); I get the following error as soon as I select a string from my combobox1 :
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.NullReferenceException: Object reference not set to an instance of an object at MainWindow.OnCombobox1Changed (System.Object sender, System.EventArgs e) [0x00000] in /home/slothofdoom/Desktop/Programming/Tracker/Tracker/MainWindow.cs:63 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in /build/mono-5.2.0.224/mcs/class/corlib/System.Reflection/MonoMethod.cs:305 --- End of inner exception stack trace --- at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00043] in /build/mono-5.2.0.224/mcs/class/corlib/System.Reflection/MonoMethod.cs:313 at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /build/mono-5.2.0.224/mcs/class/referencesource/mscorlib/system/reflection/methodbase.cs:229 at System.Delegate.DynamicInvokeImpl (System.Object[] args) [0x000e1] in /build/mono-5.2.0.224/mcs/class/corlib/System/Delegate.cs:461 at System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) [0x00008] in /build/mono-5.2.0.224/mcs/class/corlib/System/MulticastDelegate.cs:67 at System.Delegate.DynamicInvoke (System.Object[] args) [0x00000] in /build/mono-5.2.0.224/mcs/class/corlib/System/Delegate.cs:406 at GLib.Signal.ClosureInvokedCB (System.Object o, GLib.ClosureInvokedArgs args) [0x0007d] in <940f51fcd0434c359bfa4fdc8e64ad03>:0 at GLib.Signal+SignalClosure.Invoke (GLib.ClosureInvokedArgs args) [0x0000c] in <940f51fcd0434c359bfa4fdc8e64ad03>:0 at GLib.Signal+SignalClosure.MarshalCallback (System.IntPtr raw_closure, GLib.Value* return_val, System.UInt32 n_param_vals, GLib.Value* param_values, System.IntPtr invocation_hint, System.IntPtr marshal_data) [0x00050] in <940f51fcd0434c359bfa4fdc8e64ad03>:0 at GLib.ExceptionManager.RaiseUnhandledException (System.Exception e, System.Boolean is_terminal) [0x00000] in <940f51fcd0434c359bfa4fdc8e64ad03>:0 at GLib.Signal+SignalClosure.MarshalCallback (System.IntPtr raw_closure, GLib.Value* return_val, System.UInt32 n_param_vals, GLib.Value* param_values, System.IntPtr invocation_hint, System.IntPtr marshal_data) [0x00000] in <940f51fcd0434c359bfa4fdc8e64ad03>:0 at Gtk.Application.gtk_main () [0x00000] in :0 at Gtk.Application.Run () [0x00000] in :0 at Tracker.MainClass.Main (System.String[] args) [0x0002e] in /home/slothofdoom/Desktop/Programming/Tracker/Tracker/Program.cs:54
Any help with understanding how to fix this would be very appreciated
Aucun commentaire:
Enregistrer un commentaire