.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Connecting to different versions

12 REPLIES 12
Reply
Message 1 of 13
Nobody86
648 Views, 12 Replies

Connecting to different versions

Hello,

I'm new to the forum and I have a little problem which I can't solve on my own...

I wrote a C++ program which connects to AutoCAD and does some operations with sendcommand. Thanks to the really useful entries in this forum I was able to do this successfully.
Now I tried to use this program on the computer of a colleague which has a different AutoCAD version installed(2007) and I got an error message. I'm nearly one hundred percent sure that this happed because I always connected to AutoCAD 2006.

My question is:
Is there any possible way to connect to different AutoCAD-version?
12 REPLIES 12
Message 2 of 13
jerrywinters
in reply to: Nobody86

What is the error message?

Jerry
Message 3 of 13
Nobody86
in reply to: Nobody86

Unfortunately I'm not able to get to the computer of my colleague in the next days but I tried it on a older one which has AutoCAD LT 2004 installed.

I got this exception text:

System.Runtime.InteropServices.COMException (0x800401E3): Vorgang nicht verfügbar. (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))
at System.Runtime.InteropServices.Marshal.GetActiveObject(Guid& rclsid, IntPtr reserved, Object& ppunk)
at System.Runtime.InteropServices.Marshal.GetActiveObject(String progID)
at CADConn.CADConnection.Get_Point() in d:\work\cvs\vcc\arge\cadconn\cadconn.h:line 172
at ARGE.Form1.anAutoCADübergeben(Object sender, EventArgs e) in d:\work\cvs\vcc\arge\arge\form1.h:line 2073
at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ToolStrip.WndProc(Message& m)
at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

As you might guessed I used:
acadApp=(AcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application");

to connect to AutoCAD2006 and now I'm looking for a possibility to connect to other versions or at least to the newer ones(since 2006)

I tried it with GetActiveObject("AutoCAD.Application.17") but I think that I need another Interface-class for this. Correct me if I'm wrong but acax16 sounds like it only works on 16-Applications like 2006.

I hope you're able to help me...

Thanks in advance
Message 4 of 13
jerrywinters
in reply to: Nobody86

The problem may be that you are attempting to 'connect' to AutoCAD LT through COM which is not 'supported'.

Is your friend's computer running LT as well?
Message 5 of 13
Nobody86
in reply to: Nobody86

No, the 2004 AutoCAD is the only LT version but I still have a problem with connecting to different versions. It just seems that I'm not able to connect to some AutoCAD versions while some others e.g. 2005 or 2006 seem to work.
Message 6 of 13
Nobody86
in reply to: Nobody86

It seems that I made a mistake. The connection to the 2005-version also doesn't work or at least it only works on a computer with both the 2005 and the 2006 AutoCAD installed.

The error message I got was:
Could not load file or assembly 'Autodesk.AutoCAD.Interop, Version=16.2.54.0, Culture=neutral, PublicKeyToken=eed84259d7cbf30b' or one of its dependencies. The system could not find the specified file.
Message 7 of 13
jerrywinters
in reply to: Nobody86

Is it possible that your program is dealing with one Autodesk.AutoCAD.Interop version and that it is incompatible with other versions of AutoCAD?

Try removing the AutoCAD References and re-adding them on a computer with the AutoCAD version you are attempting to work with.
Message 8 of 13
Nobody86
in reply to: Nobody86

At first I want to apologize that I didn't answer faster but it was a very stressful weekend for me.

Second I already tried a different Interop version and it worked but I want to connect to as many different AutoCAD-versions as possible without changing the Interop version each time.

Thanks for your replies Jerry!
Message 9 of 13
GlennR
in reply to: Nobody86

Just a guess, but you could try changing the "Specific Version" property for that reference in the VS property dialog to false and hopefully each version of acad will find it in it's own appdomain....but like I said, just a guess...
Message 10 of 13
Nobody86
in reply to: Nobody86

I'm sorry, but there doesn't seem to be a "Specific Version" property in my Visual Studio-version. I tried to change some build properties but this doesn't seem to work either. Perhaps there is something I missed cause this solution sounds really good but at the moment I always get this error message:

Could not load file or assembly 'Autodesk.AutoCAD.Interop, Version=16.2.54.0, Culture=neutral, PublicKeyToken=eed84259d7cbf30b' or one of its dependencies.

I think that's because the program always looks on the same reference path
c:\WINDOWS\assembly\GAC\Autodesk.AutoCAD.Interop.Common\16.2.54.0__eed84259d7cbf30b\Autodesk.AutoCAD.Interop.Common.dll

instead of e.g. this one for 2005
c:\WINDOWS\assembly\GAC\Autodesk.AutoCAD.Interop.Common\16.1.63.0__eed84259d7cbf30b\Autodesk.AutoCAD.Interop.Common.dll

and therefore it's not able to find the Interop class

(Just a guess)
Message 11 of 13
GlennR
in reply to: Nobody86

Seems specific version is only available to assemblies and not COM type libraries etc.
Message 12 of 13
Nobody86
in reply to: Nobody86

Well...

I am beginning to think it's impossible but at least that's an solution too.

So does anybody know how to connect to different Interop versions or does anybody know if it's possible to connect to different Interop version?
Message 13 of 13
mahersy
in reply to: Nobody86

Have you had a look at this post:

http://discussion.autodesk.com/thread.jspa?threadID=548549

Make sure you are not copying the interop libs local.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost