Tuesday, December 15, 2015

C# and AutoCAD - The debugging challenges


The most common error one encounters while trying to debug a c# command in ACAD from visual studio is "Unknown Command xxx". The reasons one will encounter this error are:


  • The Copy Local properties for the referenced dlls - 'acdbmgd.dll' and 'acmgd.dll' is set to true in the project. This has to be set to 'False'.

  • In the acad.exe.config in the Autocad installed folder, the supported run time version is not updated depending on the .NET assembly version.
        <startup useLegacyV2RuntimeActivationPolicy="true">
               <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
                         <supportedRuntime version="v2.0.50727"></supportedRuntime>
               </startup>

        • The other reason could be that there are conflicting commands in the command file.