Casting a COMObject of TextBox type to a C# Object

109 views Asked by At

I am currently working on a application that communicates with a client. As shown below, I have a delegated method that returns the received message as a ComObject of type TextBox.

void mailbox_MessageReceived(ref object ComObj1) {
    string typeName = Microsoft.VisualBasic.Information.TypeName(ComObj1);
    Console.WriteLine(typeName); //Prints "TextBox"        

    //insert rest of code here
}

So far, I have unsuccessfully tried to cast (ComObj1 as TextBox), and tried to get the IntPtr for ComObj1 to pass as an argument in Marshal.GetObjectForNativeVariant(), both to no avail.

My question is how should I cast ComObj1 to a C# Object?

0

There are 0 answers