[Mono-bugs] [Bug 475962] exception thrown from CreateDelegate () when compiling Expression returning a delegate
    bugzilla_noreply at novell.com 
    bugzilla_noreply at novell.com
       
    Sat Feb 14 12:23:56 EST 2009
    
    
  
https://bugzilla.novell.com/show_bug.cgi?id=475962
User amirshim at yahoo.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=475962#c3
Amir Shimoni <amirshim at yahoo.com> changed:
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amirshim at yahoo.com
--- Comment #3 from Amir Shimoni <amirshim at yahoo.com>  2009-02-14 10:23:54 MST ---
It might not be the same bug exactly (or not even a bug at all), but to make
the csc compiler version fail on mono (and not on MS.net), change the last line
to
t(null); // instead of t(p);
This creates a delegate with a null target, but works on MS.net.  But it fails
on mono with the exact same exception as the original version (with t(p)).
This leads to a discrepancy between Mono and MS.net.  MS.net allows you to
create and execute a delegate on a non-static method with a null target as long
as you don't access "this" inside the method. Mono doesn't even let you create
the delegate with a null target.  I don't think this is necessarily bad, but I
think the exception should be a little more specific.  Here's a sample that
still generates the same exception as above: (Is this a MS.net bug?)
using System;
namespace MonoBug
{
    class Program
    {
        public void testFunc() {}
        static void Main()
        {
            var mi = typeof (Program).GetMethod("testFunc");
            Action a = (Action) Delegate.CreateDelegate(
               typeof (Action), null, mi);
            a();
        }
    }
}
And here's the exception it throws on Mono.
Unhandled Exception: System.ArgumentException: method argument length mismatch
  at System.Delegate.CreateDelegate (System.Type type, System.Object
firstArgument, System.Reflection.MethodInfo method, Boolean throwOnBindFailure)
[0x00266] in /mnt/photos1/dist/monosvn/mcs/class/corlib/System/Delegate.cs:259
  at System.Delegate.CreateDelegate (System.Type type, System.Object
firstArgument, System.Reflection.MethodInfo method) [0x00000] in
/mnt/photos1/dist/monosvn/mcs/class/corlib/System/Delegate.cs:263
  at MonoBug.Program.Main () [0x00015] in /tmp/test1/test2.cs:12
-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
    
    
More information about the mono-bugs
mailing list