[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pnet-developers] MethodInfo.Invoke throws unjustified exception
From: |
Gopal V |
Subject: |
Re: [Pnet-developers] MethodInfo.Invoke throws unjustified exception |
Date: |
Mon, 29 Dec 2003 01:52:57 -0800 (PST) |
Hi Bruno,
----------------------------------------
--- lib_reflect.c 2003-12-29 15:14:03.999126400 +0530
+++ lib_reflect-new.c 2003-12-29 15:17:59.938390400
+0530
@@ -2846,11 +2846,6 @@
else
{
/* Static method: we must not have a target object
*/
- if(obj)
- {
- ThrowTargetException(thread);
- return 0;
- }
}
/* Invoke the method */
----------------------------------------
Fixed ?
Would `someone like me to post this as a patch in
savannah ?
HTH,
Gopal
--- address@hidden <address@hidden> wrote:
> Using pnet-0.6.0.
>
> Invoke with a non-static method and a null object
must throw a TargetException.
> However, Invoke with a static method and a non-null
object is fine - the
> implementation should not throw an error here.
>
> ========================== hello.cs
==============================
> using System;
> using System.Reflection;
> class Hello {
> public static int FooBar () { return 42; }
> public Hello () {}
> static void Main () {
> Hello h = new Hello();
> try {
> MethodInfo m = h.GetType().GetMethod("FooBar",
new Type[0]);
> m.Invoke(h, new Object[0]);
> } catch (Exception e) {
> Console.Error.WriteLine(e);
> }
> }
> }
>
===================================================================
>
> $ cscc hello.cs -o hello.exe
> $ ilrun hello.exe
> System.Reflection.TargetException: Instance method
cannot be invoked on a null target
> at
System.Reflection.ClrMethod.Invoke(Object,
BindingFlags, Binder, Object[], CultureInfo)
> at
System.Reflection.MethodBase.Invoke(Object, Object[])
in ./System/Reflection/MethodBase.cs
> at Hello.Main()
>
>
> _______________________________________________
> Pnet-developers mailing list
> address@hidden
> http://dotgnu.org/mailman/listinfo/pnet-developers
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/