Passing Data from C# to VB6 Active X control (and vice versa)

I have an active X control written in VB6.  I am creating a C# project and need to pass data back and forth to the active x control.    Cant I just add the VB6 control to C# project reference and then be able to see public methods and send data over?   Is this possible?  What packages are needed to do this? COM.Interop?

Please help as soon as possible.


Who is Participating?
ShazbotOKConnect With a Mentor Commented:
So your wanting a C# app to consume the VB6 ActiveX?  Yes com interop would be needed, is this a UI control? you will need to add it as a resource in that case.
JohnnyKnoxvilleAuthor Commented:
The Active X control  must be registered with a 3rd party app.  This creates somewhat of a built in panel in the 3rd party app.  When the 3rd party app loads, it loads my active X control.  Now...if I have a .NET project and need to grab the handle of this active x is this accomplished?

If I simply use..

MyActiveXControl myCtrl = new MyActiveXControl();

This will give me a new instance.  What I need is the existing handle to the instance when it loaded in the 3rd party app.  I need to be able to populate data into the VB6 controls (text box , combobox, etc)

I tried to create a handle to the user control using CopyMemory  and expose it in a public class.  

Now I try this in C#...

MyActiveXControl.clsEventManagement myCtrl = new MyActiveXControl.clsEventManagement();
myCtrl.PassDataToTextBox("Some String");

This throws an error:

Retrieving the COM class Factory for component with CLSID -{21301F0D-E249-4906-9D85-87D9DE8559EF  Failed due to the following reason 80040154

Im completely stuck.  Im beginning to think its not possible to pass data back and forth because I cant get the original handle.  Is there a way to get a list of active window handles and look for my active x control?  Then try to grab it that way?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.