Hi,
I have a function that I need to call in reflection that has an out
parameter.
The following code works fine on VS2003, but not on 2005.
(I'm not receiving the out values)
Good on 2003, Bad on 2005
~~~~~~~~~~~~~~~~~~~~~
ArrayList myArgs = new ArrayList();
myArgs.Add( outVal );
obj.GetType().InvokeMember( "GetValue", BindingFlags.SetProperty |
BindingFlags.Public | BindingFlags.Instance,
null,
obj,
(Object [])myArgs.ToArray(typeof(Object)) // FAILS ON 2005
);
However, this fixes the problem:
Good on 2005
~~~~~~~~~~~
object [] myArgs = {new int() };
obj.GetType().InvokeMember( "Memory", BindingFlags.SetProperty |
BindingFlags.Public | BindingFlags.Instance,
null,
obj,
myArgs) // WORKS FINE
);
I gues this is related to a temporary array that gets lost.
Can anyone explain what's exactly happening behind the scenes, or point
me to some links?
Thanks!
Udi.