Click here to Skip to main content
15,881,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am converting an old desktop application that uses 2 ActiveX EXE's. It uses CreateObject() to return a reference to the COM object. This reference is then used to pass in pertinent information to the COM component such as database connection information and call the appropriate fuctions. There is no need to use this in IE. It is only used from this desktop app.

What would be a way to do this in .Net using C#.
Posted

1 solution

Right click References, Add Reference
select the COM tab in the dialog box and locate your activeX object - I'll call mine objA for now - and hit Ok. objA should appear in your list of references.

In your code you will need to put
C#
using objA;


Then you can use it like any other object e.g.

C#
objA a = new objA();
Debug.Print(objA.aMember.ToString());


When you build your project you will get an additional file called Interop.objA.dll which will need to live in the same folder as your exe

I've successfully used this approach with several legacy VB6 COM DLLs and EXEs - but apologies for any typos!
 
Share this answer
 
Comments
rshepp 19-Dec-12 15:37pm    
These ActiveX EXE's are going to have to be re-written for a number of reasons... The most pressing being that I cannot get them to work on the 2008 Terminal Server that I am trying to get them to work on. I would like to modernize them if at all possible and I am trying to determine the best way to do that.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900