Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Question on Reflection

Reply
 
Old 10-28-2008   #1 (permalink)
Curious


 
 

Question on Reflection

I have a C#.NET project that passes two parameters to an external S-
PLUS function that outputs a value. In my C#.NET project, I'll also
need to get the output value from S-PLUS. Therefore, this is an
integration program from C#.NET and S-PLUS.

I have C#.NET code below to pass two values for the parameters, "a"
and "b", to an S-PLUS function, "myFunction". Then the output value
from S-PLUS should be returned to my C#.NET code.

I have an issue with returned value, result. The correct "result"
should be 112. However, in my debugger, it's:

result {Dimensions:[1..2,1..2]}
[1, 1] 112

I think I should use GetType().InvokeMember to parse result in order
to get the value I need, 112. Anyone can advise me on how? Thanks!

FYI, my code is below:


Type mySFunction = Type.GetTypeFromProgID("S-
PLUS.myFunction");

object splusObject =
Activator.CreateInstance(mySFunction);

object[] oArgs = new object[1];
oArgs[0] = 112;
splusObject.GetType().InvokeMember("a",
System.Reflection.BindingFlags.SetProperty, null, splusObject, oArgs);

oArgs = new object[1];
oArgs[0] = 8;
splusObject.GetType().InvokeMember("b",
System.Reflection.BindingFlags.SetProperty, null, splusObject, oArgs);

splusObject.GetType().InvokeMember("Run",
System.Reflection.BindingFlags.InvokeMethod, null, splusObject, null);
object result =
splusObject.GetType().InvokeMember("ReturnValue",
System.Reflection.BindingFlags.GetProperty, null, splusObject, null);

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
reflection, COM, and Vista .NET General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46