From JScript to C# (COM)

P

Petar Popara

I'm looking for C# examples when calling COM objects. JScript example:

var myApp = new ActiveXObject("MyApp.1");
var res = myApp.callMethod1();

I have tried to use Google with keywords "C# COM" but it finds "COM" in
every "somewebsite.com" string. :(
 
N

Nicholas Paldino [.NET/C# MVP]

Petar,

Using COM objects in C# is a little different than Javascript. You will
need to create an interop library, and then reference it. Once you do that,
you can call it like any other object in .NET.

If you are using VS.NET, then open up the references folder in your
project, and select "Add Reference". On the dialog that comes up, select
the "COM" tab, and select the dll that has the classes you want to use. At
that point, you should have access to the classes that are in the dll.

If you are not using VS.NET then you can use the TLBIMP tool to create
an interop assembly, and then use the classes in the same way.

Hope this helps.
 
P

Petar Popara

Thank you very much. I did as you said, but don't know how to continue.
Could you please translate this in C# for me:

I have never used C# before. I just want to make few C# usage examples for
my COM object.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top