Working with ByRef parameters in COM.

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Tim Tyannikov (timofeyt_at_hotmail.com)
Date: 08/24/04


Date: 24 Aug 2004 16:26:29 -0700

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.



Relevant Pages

  • Working with ByRef parameters in COM.
    ... I have a test class called RefTest in TestByRef project. ... Public Sub Sub1(ByRef x As String) ...
    (microsoft.public.dotnet.csharp.general)
  • RE: Splitting a routine into parts
    ... Public Sub SayHello() ... ' Use the "SayHello" subroutine in the Test Class ... Ok, in the test class, we did several things, first we declared a private ...
    (microsoft.public.access.modulesdaovba)