/// and delete ref of this in Shared interface refs\r
/// </summary>\r
public virtual void ClearBinding(){\r
- if (this.DataSource == null)\r
- return;\r
object ds = this.DataSource;\r
+ if (ds == null)\r
+ return;\r
+ \r
Type dataSourceType = ds.GetType ();\r
EventInfo evtInfo = dataSourceType.GetEvent ("ValueChanged");\r
- FieldInfo evtFi = CompilerServices.GetEventHandlerField (dataSourceType, "ValueChanged");\r
- MulticastDelegate multicastDelegate = evtFi.GetValue (ds) as MulticastDelegate;\r
- if (multicastDelegate != null){ \r
- foreach (Delegate d in multicastDelegate.GetInvocationList())\r
- {\r
- string dn = d.Method.Name;\r
- if (!dn.StartsWith ("dynHandle_"))\r
- continue;\r
- int did = int.Parse (dn.Substring (10));\r
- if (this.DynamicMethodIds.Contains(did))\r
- evtInfo.RemoveEventHandler (ds, d);\r
+ if (evtInfo != null) {\r
+ FieldInfo evtFi = CompilerServices.GetEventHandlerField (dataSourceType, "ValueChanged");\r
+ MulticastDelegate multicastDelegate = evtFi.GetValue (ds) as MulticastDelegate;\r
+ if (multicastDelegate != null) { \r
+ foreach (Delegate d in multicastDelegate.GetInvocationList()) {\r
+ string dn = d.Method.Name;\r
+ if (!dn.StartsWith ("dynHandle_"))\r
+ continue;\r
+ int did = int.Parse (dn.Substring (10));\r
+ if (this.DynamicMethodIds.Contains (did))\r
+ evtInfo.RemoveEventHandler (ds, d);\r
+ }\r
}\r
}\r
\r