Author Topic: Using COM API in a .Net program for AutoCAD 2013 - Solved  (Read 5246 times)

0 Members and 1 Guest are viewing this topic.

cannorth

  • Guest
Using COM API in a .Net program for AutoCAD 2013 - Solved
« on: October 26, 2012, 11:41:47 AM »
Hello,

  I have a .Net program that's written in COM.  I'm trying to get it to work in AutoCAD 2013 but I get a COM error.  I changed my
Code: [Select]
ThisDrawing.GetObject
to version 19.  When I run the following code afterwards
Code: [Select]
Dim returnObj As AcadObject

ThisDrawing.ActiveDocument.Utility.GetEntity(returnObj, picked_pt, "Select the wellsite's closed polyline...")

I get the following COM error:

Unable to cast COM object of type 'System.__ComObject' to interface type 'Autodesk.AutoCAD.Interop.Common.AcadObject'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{425F38BA-456A-4937-8825-BEA06D12DAA2}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

  How can I fix my problem?

Thanks,

cannorth
« Last Edit: November 02, 2012, 06:06:07 PM by cannorth »

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Using COM in a .Net program for AutoCAD 2013
« Reply #1 on: October 28, 2012, 06:22:52 AM »
Quote
I have a .Net program that's written in COM.
Is it possible?

cannorth

  • Guest
Re: Using COM in a .Net program for AutoCAD 2013
« Reply #2 on: October 29, 2012, 09:55:49 AM »
I think it's possible because COM worked in AutoCAD 2012.

cannorth

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: Using COM in a .Net program for AutoCAD 2013
« Reply #3 on: October 29, 2012, 10:01:39 AM »
I have a .Net program that's written in COM.
...
I think it's possible because COM worked in AutoCAD 2012.
Maybe I incorrect understand you, but it is impossible (as far as I know) - to write .Net program through COM. May be you meaned a "run", instead  a "write"?

cannorth

  • Guest
Re: Using COM in a .Net program for AutoCAD 2013
« Reply #4 on: October 29, 2012, 10:19:53 AM »
Yes, I'm trying to run a .Net program with COM code in it and it's not working.

cannorth

cannorth

  • Guest
Re: Using COM in a .Net program for AutoCAD 2013
« Reply #5 on: October 29, 2012, 10:22:05 AM »
What I mean by COM is the AutoCAD 2013 COM Type Library.

HYPERPICS

  • Guest
Re: Using COM in a .Net program for AutoCAD 2013
« Reply #6 on: October 29, 2012, 08:38:37 PM »
Which COM library are you referencing and are you building the appropriate release?  You must target either 32-bit or 64-bit when using the COM library as it is platform specific.

There should be no problem using the COM library with AutoCAD 2013.

cannorth

  • Guest
Re: Using COM in a .Net program for AutoCAD 2013
« Reply #7 on: October 30, 2012, 10:25:20 AM »
64 bit

cannorth

  • Guest
Re: Using COM in a .Net program for AutoCAD 2013
« Reply #8 on: November 02, 2012, 05:37:56 PM »
I solved my problem.  It was a reference issue.  The Autodesk.AutoCAD.Interop.Common.dll needs to be removed from the solution to get COM functions to work.

cannorth