Author Topic: Resolving References  (Read 2316 times)

0 Members and 1 Guest are viewing this topic.

hermanm

  • Guest
Resolving References
« on: August 17, 2011, 09:02:28 PM »
How are references to the AutoCAD .NET references resolved when moving between machines?

Explicit paths to acmgd.dll, acdgmgd.dll, etc. must be provided to VS during creation of the project.

But these paths may well be different on different machines.

How is this handled?

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Resolving References
« Reply #2 on: August 17, 2011, 10:41:00 PM »
A simple non-techincal explanation is
 
When AutoCAD is installed it installs acmgd.dll, acdgmgd.dll in the same location as the acad.exe
and when acad.exe starts up it demand loads acmgd.dll, acdgmgd.dll etc..
 
So you use the dll in the sdk which are stripped out version and provide the method names and return types etc...  to be able to compile your code, that is why you set Copy local false if not then you have two copies of acmgd.dll loaded which will cause problems.
 
When a dll in loaded it will look in its output path for the referenced dll's and having copy local to true copies them in the same location.
 
 
 

hermanm

  • Guest
Re: Resolving References
« Reply #3 on: August 17, 2011, 11:06:04 PM »
A simple non-techincal explanation is
 
When AutoCAD is installed it installs acmgd.dll, acdgmgd.dll in the same location as the acad.exe
and when acad.exe starts up it demand loads acmgd.dll, acdgmgd.dll etc..
 
So you use the dll in the sdk which are stripped out version and provide the method names and return types etc...  to be able to compile your code, that is why you set Copy local false if not then you have two copies of acmgd.dll loaded which will cause problems.
 
When a dll in loaded it will look in its output path for the referenced dll's and having copy local to true copies them in the same location.

So, if  I understand correctly, the dlls in the SDK are more like a set of function prototypes, which do not contain the actual code, only the input/output specs., in order to validate the function references for compilation. Is that correct? I was confounded as to why they were so much smaller...

Makes sense not to have competing versions loaded.

But if I reference the actual assemblies in the ACAD install directory & set Copy Local to false, would that not accomplish the same thing? If that is the case, then the only advantage  I can see to referencing the SDK versions would be a) slightly faster compilation and b)  not having to repath references in the project in case you wish to modify existing code & have, for some reason, moved your AutoCAD installation. This seems like a very marginal advantage to me, but perhaps I am not grasping all implications.

@ kdub:

It will take me awhile to absorb this completely, but thanks very much for the references. I am sure others here will benefit as well. What I am getting right now is, the .NET runtime does most of this for you, but you can override its default protocol via your own configuration file.

Thanks, guys. :-)
« Last Edit: August 17, 2011, 11:12:24 PM by hermanm »

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Re: Resolving References
« Reply #4 on: August 17, 2011, 11:30:38 PM »

You are essentially correct about using the SDK dll's ... their use is NOT mandatory.

However this post by Norman at the ADNG highlights a couple of points worth considering

http://forums.autodesk.com/t5/NET/Getting-Started/m-p/2898280#M22474

Regards,
Kerry
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Resolving References
« Reply #5 on: August 17, 2011, 11:45:35 PM »
I do not remeber what it had to do with but I remeber Tony T saying that there are some things that will cause the VS IDE to crash if you use the ones installed with Acad

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2140
  • class keyThumper<T>:ILazy<T>
Re: Resolving References
« Reply #6 on: August 17, 2011, 11:58:03 PM »
Hi Jeff,
I recall the same statement, but can't place the details or timeframe ..
I also recall the same recommendation from several people associated with AutoDesk technical support.

I use the SDK as a matter of course and haven't 'tried' to break the IDE :)

As a side thought ... using the SDK (a particular build) may help with dependency issues for a previous class/method requirement.
ie. If you use an older SDK only the defined class/method definitions will be available in the IDE.
( This of course may be a 2 edged sword :) )
Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

hermanm

  • Guest
Re: Resolving References
« Reply #7 on: August 18, 2011, 12:23:19 AM »
.

However this post by Norman at the ADNG highlights a couple of points worth considering

http://forums.autodesk.com/t5/NET/Getting-Started/m-p/2898280#M22474

Regards,
Kerry

This in particular caught my eye:

Quote

Also, path to Autodesk.AutoCAD.Interop/Interop.Common being changed or not really does not matter, they are installed in GAC by AutoCAD. If you set reference to them from SDK folder (or anywhere in the disk), you do not copy them to output location (Copy Local =False) anyway, and AutoCAD (actually the .NET runtime) always look for it in GAC first.


Also, I agree with this, at least for a novice (raising hand):
Quote
So, I do recommend the start a blank class library project (VB.NET or C#), set references to acdbmgd/acmgd.dll(make sure "Copy Local to False), maybe add some boiler plate code in a class and then export it as your basic Acad .NET API development template

vs. using a "wizard."

I want control & knowledge of what I am doing.

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Resolving References
« Reply #8 on: August 18, 2011, 11:15:22 AM »
For what its worth, I'm now compiling against the SDK DLLs which I'm keeping on the network rather than on the local drive.  The finished distributed DLLs are run from their own local drive with no issues, even though the users don't have access to that particular network location.  That, to me, would confirm the AutoCAD DLLs are being loaded from the GAC.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}