Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Micko

C# with COM

This topic is 5279 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m trying to use a COM dll that is an add on to an application that I''m connecting to using C#. Its an add on for AutoCAD and I need to get an instance of it to extract info from the drawing of these custom objects. Here''s how it''s done in vb-
''connect to Acad
Set acadApp = CreateObject("AutoCAD.Application")

''connect to Acad add on
Set Obj = acadApp.GetInterfaceObject("SOMECOMWRAPPER.SomeComApplication")                
If Not Obj Is Nothing Then                        
	MsgBox "Found installed SomeAddOnApp version " & Obj.VersionString            
               
End If  
Any help appreciated.Mick

Share this post


Link to post
Share on other sites
Advertisement
It's pretty straight forward in C# (and I believe it's the same procedure for VB.NET), though it's not quite as simple as in VB.

1) Run tlbimp on the native binary that has your COM component in it.

2) Declare a COM coclass in your C# source, using the ComImportAttribute.

3) Create the class and run with it. You have to add the managed assembly generated in step 1 as a reference to your C# project.

Here's the tutorial on how to do COM Interop in C#


[edited by - Alias2 on June 2, 2004 2:49:07 AM]

Share this post


Link to post
Share on other sites
Thanks Alias2, I''ll let you know how I get on after getting my head around that.
Cheers.Mick

Share this post


Link to post
Share on other sites
If you are using Visual Studio then it''s enough to just add a reference directly to the COM dll. VS will automatically create the managed wrapper and reference it, so you can work with the COM dll just the same as with a normal managed dll.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!