[Mono-bugs] [Bug 360784] New: [Regression] Delegate. CreateDelegate does not support private methods in base class

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon Feb 11 16:26:24 EST 2008


https://bugzilla.novell.com/show_bug.cgi?id=360784


           Summary: [Regression] Delegate.CreateDelegate does not support
                    private methods in base class
           Product: Mono: Class Libraries
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: CORLIB
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: gert.driesen at pandora.be
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


The Delegate.CreateDelegate overloads that take a method name no longer support
private methods in base types of the specified target (type or object).

This is probably a result of our (my) fixes to Type.GetMethods, which now
behaves like MS.

The code in Delegate.CreateDelegate apparently relies on our broken
implementation of Type.GetMethods.

I'll add unit tests for this issue first - to discover the exact MS
implementation of the overloads - and then submit a patch for review.

To reproduce, compile and run the following code:

using System;
using System.Reflection;

class Program
{
  static void Main ()
  {
    Bar b = new Bar ();

    EventHandler handler = (EventHandler ) Delegate.CreateDelegate (
      typeof (EventHandler), b, "Page_Load");
    handler (b, new EventArgs ());
  }
}

class Foo
{
  void Page_Load (object sender, EventArgs e)
  {
  }
}

class Bar : Foo
{
}

Expected result:

Successful execution

Actual result:

Unhandled Exception: System.ArgumentException: Couldn't bind to method
'Page_Loa
d'.
  at System.Delegate.CreateDelegate (System.Type type, System.Object target,
Sys
tem.String method, Boolean ignoreCase, Boolean throwOnBindFailure) [0x00000]
  at System.Delegate.CreateDelegate (System.Type type, System.Object target,
Sys
tem.String method, Boolean ignoreCase) [0x00000]
  at System.Delegate.CreateDelegate (System.Type type, System.Object target,
Sys
tem.String method) [0x00000]
  at Program.Main () [0x00000]


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list