Sorry for replying to myself, but this new patch (which obsoletes the
previous one) fixes the same problem in all the overloaded versions of
Delegate.CreateDelegate.

El mar, 03-09-2002 a las 15:52, Ricardo Fern�ndez Pascual escribi�:
> 
> Hi,
>     The following patch fixes a crash in mono when invoking
> Delegate.Createdelegate(Type,object,string) with a wrong method name
> string. Also, I think this is what the docs say that should be done.
> 
> The doc that I used is:
> 
>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdelegateclasscreatedelegatetopic2.asp
> 
> Greetings,
> Ricardo


-- 
Ricardo Fern�ndez Pascual
[EMAIL PROTECTED]
Murcia. Espa�a.
Index: class/corlib/System/Delegate.cs
===================================================================
RCS file: /mono/mcs/class/corlib/System/Delegate.cs,v
retrieving revision 1.19
diff -u -r1.19 Delegate.cs
--- class/corlib/System/Delegate.cs     19 Aug 2002 13:27:58 -0000      1.19
+++ class/corlib/System/Delegate.cs     3 Sep 2002 13:58:39 -0000
@@ -98,6 +98,11 @@
 
                        BindingFlags flags =  BindingFlags.Public | 
BindingFlags.Instance;
                        MethodInfo info = target.GetType ().GetMethod (method, flags);
+                       
+                       if (info == null)
+                               throw new ArgumentException 
+                                       (Locale.GetText ("method string is not an 
+instance method name"));
+
                        return CreateDelegate_internal (type, target, info);
                }
 
@@ -114,6 +119,11 @@
 
                        BindingFlags flags =  BindingFlags.Public | 
BindingFlags.Static;
                        MethodInfo info = target.GetMethod (method, flags);
+
+                       if (info == null)
+                               throw new ArgumentException 
+                                       (Locale.GetText ("method string is not a 
+static method name"));
+
                        return CreateDelegate_internal (type, null, info);
                }
 
@@ -131,6 +141,11 @@
                        Type target_type = target.GetType ();
                        BindingFlags flags =  BindingFlags.Public | 
BindingFlags.Instance | BindingFlags.IgnoreCase;
                        MethodInfo info = target_type.GetMethod (method, flags);
+
+                       if (info == null)
+                               throw new ArgumentException 
+                                       (Locale.GetText ("method string is not an 
+instance method name"));
+
                        return CreateDelegate_internal (type, target, info);           
         
                }
 

Reply via email to