For Programmers: Free Programming Magazines  


Home > Archive > C# > August 2004 > Working with ByRef parameters in COM.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Working with ByRef parameters in COM.
Tim Tyannikov

2004-08-24, 11:05 pm

I have a test class called RefTest in TestByRef project. The class
has only one method:

Public Sub Sub1(ByRef x As String)
x = "asdf"
End Sub

In my test C# project I have:

Type t = Type.GetTypeFromProgID("TestByRef.RefTest", true);
object test = Activator.CreateInstance(t);

object [] args = new object[1]{null};

test.GetType()
.InvokeMember("Sub1"
, System.Reflection.BindingFlags.InvokeMethod
,null,test, args);

txtTestMethodResult.Text = args[0].ToString();

This code does not take me anywhere. The value of args[0] is always
null; not "asdf" as I expect.
Can somebody please tell me what is it that I am doing wrong?

Thank you,
Tim.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com