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

Build for multiple Autocad versions

17 REPLIES 17
Reply
Message 1 of 18
ChrisArps
934 Views, 17 Replies

Build for multiple Autocad versions

The interop assembly being provided by Autodesk and going through activex interfaces creates a unique problem.

I can only build for one version at a time, if I have 2006 installed and write a .net app for Autocad, it will not run on a system with only 2005 installed.

To solve this and be able to build for both 2005 and 2006, I had to build a batch file that unregisters the 2006 interop and registers the 2005 one (boring).

Not a major issue, but it adds an extra complicated step that dot net is supposed to eliminate.
17 REPLIES 17
Message 2 of 18
Anonymous
in reply to: ChrisArps

CArps wrote:

> Not a major issue, but it adds an extra complicated step that dot net
> is supposed to eliminate.

If you're willing to accept the performance penalty, it's possible to use
late binding thus freeing you from the problem.

I wouldn't recommend it for intense purposes but it's a great solution for
querying drawings.
Message 3 of 18
Anonymous
in reply to: ChrisArps

Another thing you can do is use binding redirect in acad.exe.config.
1. Build against the R2005 version of the interop assemblies.
2. Add the following to acad.exe.config on R2006. I haven't tried this so I
may have some silly typos. It shows the idea nonetheless:




publicKeyToken="eed84259d7cbf30b" culture="neutral" />




publicKeyToken="eed84259d7cbf30b" culture="neutral" />







wrote in message news:4849652@discussion.autodesk.com...
The interop assembly being provided by Autodesk and going through activex
interfaces creates a unique problem.

I can only build for one version at a time, if I have 2006 installed and
write a .net app for Autocad, it will not run on a system with only 2005
installed.

To solve this and be able to build for both 2005 and 2006, I had to build a
batch file that unregisters the 2006 interop and registers the 2005 one
(boring).

Not a major issue, but it adds an extra complicated step that dot net is
supposed to eliminate.
Message 4 of 18
Anonymous
in reply to: ChrisArps

And yet another solution is to use your own interop assembly (based on say
the R2004 version of the typelib). You don't have to use the PIA. Using your
own interop assembly will make you redistributable bigger but it will work
for R2004, 2005, 2006.

Albert

wrote in message news:4849652@discussion.autodesk.com...
The interop assembly being provided by Autodesk and going through activex
interfaces creates a unique problem.

I can only build for one version at a time, if I have 2006 installed and
write a .net app for Autocad, it will not run on a system with only 2005
installed.

To solve this and be able to build for both 2005 and 2006, I had to build a
batch file that unregisters the 2006 interop and registers the 2005 one
(boring).

Not a major issue, but it adds an extra complicated step that dot net is
supposed to eliminate.
Message 5 of 18
ChrisArps
in reply to: ChrisArps

That could break other applications or introduce old framework bugs into R2006 itself. I have to remain interoperable with other plugins for ADT.
Message 6 of 18
Anonymous
in reply to: ChrisArps

I also have this problem, and I like the idea of a batch file fix, are you
willing to post the text contained in your batch file please....

Laurence
wrote in message news:4849652@discussion.autodesk.com...
The interop assembly being provided by Autodesk and going through activex
interfaces creates a unique problem.

I can only build for one version at a time, if I have 2006 installed and
write a .net app for Autocad, it will not run on a system with only 2005
installed.

To solve this and be able to build for both 2005 and 2006, I had to build a
batch file that unregisters the 2006 interop and registers the 2005 one
(boring).

Not a major issue, but it adds an extra complicated step that dot net is
supposed to eliminate.
Message 7 of 18
Anonymous
in reply to: ChrisArps

Yep. This may break other R2006 based apps that rely on R2006-only features.

Albert

wrote in message news:4850121@discussion.autodesk.com...
That could break other applications or introduce old framework bugs into
R2006 itself. I have to remain interoperable with other plugins for ADT.
Message 8 of 18
ChrisArps
in reply to: ChrisArps

That will not work as you can only have one primary interop assembly linked to an activex typelib.

Since the version of the typelib has not changed, there is no way to accomplish this without unregistering the PIA on the end users machine.

Plus you will lose some of the .net only objects that are in Autodesks PIA.

The solution is for Autodesk to provide a real dot net dll and get rid of activex. As long as the registry is involved, you will have to deal with "dll hell".
Message 9 of 18
Anonymous
in reply to: ChrisArps

CArps wrote:
> That will not work as you can only have one primary interop assembly
> linked to an activex typelib.

As he said: you are not forced to use the PIA. Simply create a local
assembly using TLBIMP. As long as you specify the namespace to be
contained by your assembly, it'll work just fine.
Message 10 of 18
ChrisArps
in reply to: ChrisArps

Sure, the first two steps you will have to do manually to setup for your compiles/builds.

1) Locate the Autodesk .dll files in the GAC. You cannot use windows explorer for this, you have to use the good old command line with cd and dir.

CD \winnt\assembly\GAC
xcopy *.* c:\temp\junk /S

This will copy all the subdirs and all dlls in the gac so you can get at them with explorer.

2) Find the appropriate Autodesk folders and copy the dlls to a nice location for your builds for ease of use.You will need a folder for each version.

Now that we have the dotnet dlls you can now setup for builds.

Assuming we are building the 2006 version of the program:

3) Execute the unregister batch file for 2005 (shown below)
cd Assembly
cd ADT45
%Framework%\regasm Autodesk.AEC.Interop.ArchBase.dll /u
%Framework%\regasm Autodesk.AEC.Interop.Base.dll /u
%Framework%\regasm Autodesk.AEC.Interop.UIArchBase.dll /u
%Framework%\regasm Autodesk.AEC.Interop.UIBase.dll /u
%Framework%\regasm Autodesk.AutoCAD.Interop.dll /u
%Framework%\regasm Autodesk.AutoCAD.Interop.Common.dll /u
cd ..
cd ..

if (%1)==(AUTO) goto :EOF
pause

4) Execute the register batch file for 2006 (shown below)
cd Assembly
cd ADT47
%Framework%\regasm Autodesk.AEC.Interop.ArchBase.dll
%Framework%\regasm Autodesk.AEC.Interop.Base.dll
%Framework%\regasm Autodesk.AEC.Interop.UIArchBase.dll
%Framework%\regasm Autodesk.AEC.Interop.UIBase.dll
%Framework%\regasm Autodesk.AutoCAD.Interop.dll
%Framework%\regasm Autodesk.AutoCAD.Interop.Common.dll
cd ..
cd ..

if (%1)==(AUTO) goto :EOF
pause

There are 4 batch files, reg and unreg for 2005, reg and unreg for 2006. Thist allows a developer to be on 2006 and we can build for both versions (as long as he doesn't use any 2006 only features).
Message 11 of 18
ChrisArps
in reply to: ChrisArps

I tried this yesterday testing a new program, ADT 2006 will not even run after changing the config file.

I have no idea about Autocad2006, but I suspect it will crash as well.
Message 12 of 18
Anonymous
in reply to: ChrisArps

Cheers, thanks for the full explanation, will give it a go

Laurence
wrote in message news:4851112@discussion.autodesk.com...
Sure, the first two steps you will have to do manually to setup for your
compiles/builds.

1) Locate the Autodesk .dll files in the GAC. You cannot use windows
explorer for this, you have to use the good old command line with cd and
dir.

CD \winnt\assembly\GAC
xcopy *.* c:\temp\junk /S

This will copy all the subdirs and all dlls in the gac so you can get at
them with explorer.

2) Find the appropriate Autodesk folders and copy the dlls to a nice
location for your builds for ease of use.You will need a folder for each
version.

Now that we have the dotnet dlls you can now setup for builds.

Assuming we are building the 2006 version of the program:

3) Execute the unregister batch file for 2005 (shown below)
cd Assembly
cd ADT45
%Framework%\regasm Autodesk.AEC.Interop.ArchBase.dll /u
%Framework%\regasm Autodesk.AEC.Interop.Base.dll /u
%Framework%\regasm Autodesk.AEC.Interop.UIArchBase.dll /u
%Framework%\regasm Autodesk.AEC.Interop.UIBase.dll /u
%Framework%\regasm Autodesk.AutoCAD.Interop.dll /u
%Framework%\regasm Autodesk.AutoCAD.Interop.Common.dll /u
cd ..
cd ..

if (%1)==(AUTO) goto :EOF
pause

4) Execute the register batch file for 2006 (shown below)
cd Assembly
cd ADT47
%Framework%\regasm Autodesk.AEC.Interop.ArchBase.dll
%Framework%\regasm Autodesk.AEC.Interop.Base.dll
%Framework%\regasm Autodesk.AEC.Interop.UIArchBase.dll
%Framework%\regasm Autodesk.AEC.Interop.UIBase.dll
%Framework%\regasm Autodesk.AutoCAD.Interop.dll
%Framework%\regasm Autodesk.AutoCAD.Interop.Common.dll
cd ..
cd ..

if (%1)==(AUTO) goto :EOF
pause

There are 4 batch files, reg and unreg for 2005, reg and unreg for 2006.
Thist allows a developer to be on 2006 and we can build for both versions
(as long as he doesn't use any 2006 only features).
Message 13 of 18
Anonymous
in reply to: ChrisArps

Can you just confirm the version numbers please. I have v16.2.54.0 which I
assume is 2006 and version 16.1.63.0 which I assume is 2005?

Laurence
wrote in message news:4851112@discussion.autodesk.com...
Sure, the first two steps you will have to do manually to setup for your
compiles/builds.

1) Locate the Autodesk .dll files in the GAC. You cannot use windows
explorer for this, you have to use the good old command line with cd and
dir.

CD \winnt\assembly\GAC
xcopy *.* c:\temp\junk /S

This will copy all the subdirs and all dlls in the gac so you can get at
them with explorer.

2) Find the appropriate Autodesk folders and copy the dlls to a nice
location for your builds for ease of use.You will need a folder for each
version.

Now that we have the dotnet dlls you can now setup for builds.

Assuming we are building the 2006 version of the program:

3) Execute the unregister batch file for 2005 (shown below)
cd Assembly
cd ADT45
%Framework%\regasm Autodesk.AEC.Interop.ArchBase.dll /u
%Framework%\regasm Autodesk.AEC.Interop.Base.dll /u
%Framework%\regasm Autodesk.AEC.Interop.UIArchBase.dll /u
%Framework%\regasm Autodesk.AEC.Interop.UIBase.dll /u
%Framework%\regasm Autodesk.AutoCAD.Interop.dll /u
%Framework%\regasm Autodesk.AutoCAD.Interop.Common.dll /u
cd ..
cd ..

if (%1)==(AUTO) goto :EOF
pause

4) Execute the register batch file for 2006 (shown below)
cd Assembly
cd ADT47
%Framework%\regasm Autodesk.AEC.Interop.ArchBase.dll
%Framework%\regasm Autodesk.AEC.Interop.Base.dll
%Framework%\regasm Autodesk.AEC.Interop.UIArchBase.dll
%Framework%\regasm Autodesk.AEC.Interop.UIBase.dll
%Framework%\regasm Autodesk.AutoCAD.Interop.dll
%Framework%\regasm Autodesk.AutoCAD.Interop.Common.dll
cd ..
cd ..

if (%1)==(AUTO) goto :EOF
pause

There are 4 batch files, reg and unreg for 2005, reg and unreg for 2006.
Thist allows a developer to be on 2006 and we can build for both versions
(as long as he doesn't use any 2006 only features).
Message 14 of 18
Anonymous
in reply to: ChrisArps

My fault, test PC has 2006 so uninstalled and tried, failed, so repaired
2005 installation, worked.

Batch files - Great solution CArps

Laurence
"Laurence Skoropinski" wrote in message
news:4851451@discussion.autodesk.com...
Can you just confirm the version numbers please. I have v16.2.54.0 which I
assume is 2006 and version 16.1.63.0 which I assume is 2005?

Laurence
wrote in message news:4851112@discussion.autodesk.com...
Sure, the first two steps you will have to do manually to setup for your
compiles/builds.

1) Locate the Autodesk .dll files in the GAC. You cannot use windows
explorer for this, you have to use the good old command line with cd and
dir.

CD \winnt\assembly\GAC
xcopy *.* c:\temp\junk /S

This will copy all the subdirs and all dlls in the gac so you can get at
them with explorer.

2) Find the appropriate Autodesk folders and copy the dlls to a nice
location for your builds for ease of use.You will need a folder for each
version.

Now that we have the dotnet dlls you can now setup for builds.

Assuming we are building the 2006 version of the program:

3) Execute the unregister batch file for 2005 (shown below)
cd Assembly
cd ADT45
%Framework%\regasm Autodesk.AEC.Interop.ArchBase.dll /u
%Framework%\regasm Autodesk.AEC.Interop.Base.dll /u
%Framework%\regasm Autodesk.AEC.Interop.UIArchBase.dll /u
%Framework%\regasm Autodesk.AEC.Interop.UIBase.dll /u
%Framework%\regasm Autodesk.AutoCAD.Interop.dll /u
%Framework%\regasm Autodesk.AutoCAD.Interop.Common.dll /u
cd ..
cd ..

if (%1)==(AUTO) goto :EOF
pause

4) Execute the register batch file for 2006 (shown below)
cd Assembly
cd ADT47
%Framework%\regasm Autodesk.AEC.Interop.ArchBase.dll
%Framework%\regasm Autodesk.AEC.Interop.Base.dll
%Framework%\regasm Autodesk.AEC.Interop.UIArchBase.dll
%Framework%\regasm Autodesk.AEC.Interop.UIBase.dll
%Framework%\regasm Autodesk.AutoCAD.Interop.dll
%Framework%\regasm Autodesk.AutoCAD.Interop.Common.dll
cd ..
cd ..

if (%1)==(AUTO) goto :EOF
pause

There are 4 batch files, reg and unreg for 2005, reg and unreg for 2006.
Thist allows a developer to be on 2006 and we can build for both versions
(as long as he doesn't use any 2006 only features).
Message 15 of 18
ChrisArps
in reply to: ChrisArps

I tried that out and it will work, but I lose the AcGe library in 2005,2006 code. I will just stick to the batch trick as it only affects the build machine and does not impact development environments.
Message 16 of 18
phreakie
in reply to: ChrisArps

I too am trying to build for 2 versions, vanilla ACAD 2005 & 2006. I am also learning vb.net. I tried the batch trick you described below but it didn't work. regasm told me that all registers and unregisters were successfull. I am still getting errors for ALL of my Imports such as this:

Namespace or type 'ApplicationServices' for the Imports 'Autodesk.AutoCAD.ApplicationServices' cannot be found.

Anybody know what I am doing wrong? I have correctly referenced the right AutoCAD DLL's.
Message 17 of 18
Anonymous
in reply to: ChrisArps

CArps, this is a really great work! I will try this too. Message was edited by: cadprog
Message 18 of 18
andrei.petre
in reply to: ChrisArps

The best would be to use "dynamic" type in c#, check here https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/dynamic.

This way will no longer need to reference the assembly, therefor no need to worry about versions of interops.

 

Just used it and it worked.

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