开发者

System.EventHandler conversion Error

开发者 https://www.devze.com 2023-02-14 20:43 出处:网络
I have an Info class which has following event. public delegate void GroupNameChangedHandler(string groupName);

I have an Info class which has following event.

    public delegate void GroupNameChangedHandler(string groupName);
    [field: NonSerialized]
    public event GroupNameChangedHandler GroupNameChanged;

one other class is registered to that event. It seems working fine, but yesterday one of our client mentioned that application is throwing some exception and following is stack trace of that error. I am not sure what is wrong on client's machine or application. This is working well for almost 50 of other users.

Object of type 'System.EventHandler' cannot be converted to type 'EZOMS.OrderEntry.PairsOrderInfo+GroupNameChangedHandler'. (mscorlib)


 Program Location:

   at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
   at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.ComponentModel.ReflectEventDescriptor.RemoveEventHandler(Object component, Delegate value)
   at System.ComponentModel.ReflectPropertyDescriptor.RemoveValueChanged(Object component, EventHandler handler)
   at System.Windows.Forms.BindingSource.UnwirePropertyChangedEvents(Object item)
   at System.Windows.Forms.BindingSource.Clear()
   at EZOMS.OrderEntry.PairsOrderEntryForm.LoadPairsOrderInfo(PairsOrderInfo pairsOrderInfo) in C:\de开发者_开发百科v\BRANCH\EZOMS\OrderEntry\PairsOrderEntryForm.cs:line 1063
   at EZOMS.OrderEntry.PairsOrderEntryForm.buttonSave_Click(Object sender, EventArgs e) in C:\dev\BRANCH\EZOMS\OrderEntry\PairsOrderEntryForm.cs:line 765
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


It sounds like you have a property called GroupName; there is a convention for change handlers to follow the event EventHandler *Changed pattern, so the binding code (in the property-descriptor, mainly) spots this pattern and tries to subscribe with an event-handler. In this case, it is fairly doomed.

You might want to check that they are using the same .NET version (including service packs); maybe this was improved in later versions.

Of course, assuming there is a GroupName property, you could just switch back to EventHandler and have the subscriber query from there.

0

精彩评论

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