Wednesday, September 13, 2006

.NET vs. COM in AutoCAD - What should I use?

Kean Walmsley writes about the pros and cons of .NET vs. COM in AutoCAD on the "Through the Interface" blog.

In general, a good article - but I don't think it addresses two of the biggest "gotchas" of AutoCAD.NET...

The Blessing/Curse of Versions
One of the goals of .NET was to avoid some of the issues of "DLL Hell", where different programs linked with different versions of DLLs without worrying about whether the differences were significant.

Now when I make an AutoCAD.NET application, it gets linked against the file "acmgd.dll" version 17.0.54.0 (in vanilla AutoCAD 2007). If 17.0.54.0 is not available later, you're out of luck...

Problem #1: Versions within AutoCAD and vertical Releases
In the AutoCAD 2005 release, we ran into a problem where vanilla AutoCAD was version 16.1.63.0, but the version of Autodesk Map3D 2005 and in various service packs was version 16.1.84.0...

Now - Autodesk has been far better about being nice about not changing the version randomly in 2006 and 2007... But there may come a time when it's necessary in mid-release, and that makes a lot of stuff break!

Problem #2: Versions between AutoCAD Releases
This one there's really no getting around... Each release of AutoCAD will have a different version of acmgd.dll... And as a result, your application will need to be recompiled for each version.

This is a disadvantage compared to both ARX and COM... In ARX, Autodesk has been fairly succesful at making ARX applications binary compatible within 3 release blocks (2004, 2005, 2006, for example)... With COM, I suspect because the COM layer "insulates" the application from changes even further, there are people who can still run the VB application they wrote for AutoCAD 2000 in AutoCAD 2007 (OK, so there might be some changes - but it's the exception rather than the rule)...

Summary
Don't get me wrong - I'm still a HUGE fan of .NET for application development... But the benefits that it brings are not without their costs compared to ARX and COM. I've also noticed that there may be some relief from this in Visual Studio 2005 (although I don't quite have my head wrapped around the "Specific Version=FALSE" option).

Editor's Update: Kean has put in a comment that clarifies this issue:
http://www.blogger.com/comment.g?blogID=23382408&postID=115816634885341203
The short, tongue-in-cheek version: In 2005, 2006 and 2007 it was intentionally broken, but going forward it will be the same as ARX ... So 2007,2008, and 2009 would presumably be binary compatible. Thanks Kean!

4 comments:

Kean said...

Hi Matt,

Thanks for your feedback (I’m impressed with how quickly it came, as well! :-)

A couple of comments on your blog post:

“If 17.0.54.0 is not available later, you're out of luck...”

Actually, no: acmgd.dll is no longer strongly signed, so the version of the assembly should not be considered during binding. Later versions of acmgd.dll should work, too, unless there’s been a signature change (more on this later). It was absolutely a problem with AutoCAD 2005, but we fixed it in 2006.

“Each release of AutoCAD will have a different version of acmgd.dll... And as a result, your application will need to be recompiled for each version.”

Again, this isn’t quite right. In theory you should not need to re-compile for each version unless there are signature changes.

So, when do we allow signature changes?

We introduced the managed API in AutoCAD 2005, but there was a lot more we needed to do to make it complete enough for serious use. So between AutoCAD 2005 and 2006 the decision was made not to enforce compatibility at a signature level.

Between AutoCAD 2006 and 2007 we deliberately broke compatibility, yes, but that was in sync with the overall break in application compatibility.

As we are aiming to maintain application compatibility between AutoCAD 2007 and the next two releases, you should experience the same level of compatibility you have enjoyed with ObjectARX.

Cheers,

Kean

Todd M. Shackelford said...

Matt,

Always interesting reading. Thanks for the insight and keep up the great work.

Stravadi said...

Hi.i googled for help and found your blog.I have both autocad 2000 and 2007 on my system.i worked on acad2007 and saved my file as an acad2000 form.when i opened it with acad2000 ,although it works fine i couldnt copy and paste the drawing (a line for example).The problem is that i must copy these drawings in some other ones and i cant do it.it copies them but when i try to paste them a "_pasteclip" appears in the command line and nothing happens?is there a compatibility problem?i reaaly need help on this becouse i must have this work ready soon.

58734162 said...

hello,I recommend to you the best browser in history,I really loved it,I hope you may want to download and try. thank you.