all groups > vb.net upgrade > august 2004 >
You're in the

vb.net upgrade

group:

Getting values from a COM object through ByRef parameters.



Getting values from a COM object through ByRef parameters. timofeyt NO[at]SPAM hotmail.com
8/25/2004 2:51:08 PM
vb.net upgrade: I asked this question in C# groups but did not get any response back.
I decided to try my luck here. My problem is that I can't get values
from a COM object through ByRef parameters using InvokeMember method.
Here is a very simple example in VB6 + C#:

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?

Your response is greatly appreciated,
Re: Getting values from a COM object through ByRef parameters. Patrick Steele [MVP]
9/2/2004 1:04:24 PM
In article <a85c61c8.0408251351.7da19323@posting.google.com>,
timofeyt@hotmail.com says...
[quoted text, click to view]

See this article:

http://www.google.com/groups?selm=BC4gFoXoCHA.1928%40cpmsftngxa06

--
Patrick Steele
Microsoft .NET MVP
AddThis Social Bookmark Button