I have a .NET app that I have created to run inside of AutoCAD. It runs inside of AutoCAD and has been tested on both AutoCAD 2010 and 2012. I have also built a standalone applicaiton that is intended to start AutoCAD and netload the in process dll. I have a computer that has 2010 installed and if I compile the application on this machine everything works as it should. If I then run the same standalone application on a computer that only has 2012 installed it doesn't connect. It starts AutoCAD (acad.exe shows up in the task manager) but it can't connect to it. I then tested the opposite scenario. Built the standalone application on a computer that only has 2012 installed and it works with AutoCAD 2012. I then ran that applicaiton on the computer with only AutoCAD 2010 installed and it can't connect. Just like before, acad.exe is started but it doesn't connect and instead gives an error.
Obviously this would make supporting different versions of AutoCAD require a different executables for the standalone application which seems wrong. I have created a applicaiton that communicates with Inventor and this problem did not occur. Thus, I had assumed it wouldn't be an issue with AutoCAD. Am I doing something wrong that is preventing the different versions from working? Any help would be greatly appreciated.
Here is the code for connecting to AutoCAD.
public void connectAutoCad()
String progID = "Application.AutoCAD";
//try to connect an open instance of autoCad
acApp = (AcadApplication)Marshal.GetActiveObject(progID);
//open a new instance autoCad
Type acType = Type.GetTypeFromProgID(progID);
Have you tried setting the visibility using "acApp.Visible = true" after "CreateInstance" call ?
Does AutoCAD then show up ?
I have 2011 and 2012 installed and it works ok when i launch 2012.
Here are few things that you may try :
1) Check the following in the registry - HKEY_CLASSES_ROOT\AutoCAD.Application
Use the CLSID mentioned to search and this should lead you to the acad.exe path that is supposed to get launched. Make sure you do this carefully and dont change anything by mistake.
2) Try invoking a specific version by providing a different progId such as "AutoCAD.Application.18" and "AutoCAD.Application.18.2".
3) See if the issue is specific to a system by trying it on other systems that only have 2012.
So just to confirm, a single excutable that is created on a computer using AutoCAD 2012 should be able to connect to AutoCAD when the application is installed on a computer that only contains AutoCAD 2010?
I still haven't found a solution for my problem. Does anyone have experience with connecting to multiple different versions of AutoCAD with a single executable? Any help would be greatly appreciated.
Try to get the current version something like this
Dim acadver As Object
acadver = My.Computer.Registry.GetValue("HKEY_CLASSES_ROOT\A
If typeOf acadver Is String Then
MessageBox.Show("String acadver: " & acadver.ToString
Then pull this string to CreateInstance method from
Same problem still exists. It starts acad.exe but cannot connect to it. Any other opitons? This seems like it should be pretty straight forward. How else can a stand along application support multiple versions of AutoCAD?