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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.