NP CAD Page | Articles | Download | Russian

N.Poleshchuk. Wizard problems arising in creation of a new managed application (C# or VB.NET) for AutoCAD 2010

After installation of Wizards for ObjectARX (version 2005 and higher) you automatically get Wizards for creation of managed applications in C# and Visual Basic.NET programming languages. Unfortunately new application skeleton you are getting for version 2010 contains some faults preventing from normal work.

DLL Problem

1. When creating a skeleton for the new project of types "AutoCAD Managed C# Project" and "AutoCAD Managed VB Project Application" you get the following error message:

Error is caused by improper search of the AcMgd.dll and AcDbMgd.dll libraries during work of scripts located in the files D:\ObjectARX 2010 Wizards for AutoCAD 2010\AutoCAD Managed CS App\Scripts\1033\default.js and ObjectARX 2010 Wizards for AutoCAD 2010\AutoCAD Managed VB App\Scripts\1033\default.js (in assumption that you chose folder D:\ObjectARX 2010 Wizards for AutoCAD 2010 while installing).
The following part of default.js is responsible for libraries addition:

//- Add references to acmgd.dll abd acdbmgd.dll
var strAcadPath = FindAutoCAD();
var strCompleteAcadPath =strAcadPath + 'acad.exe';
var strAcmgdPath =strAcadPath + 'acmgd.dll' ;
var strAcdbmgdPath = strAcadPath + 'acdbmgd.dll';
var strAcCuiPath = strAcadPath + 'AcCui.dll';
//wizard.OkCancelAlert (configMgr.Item(1).ConfigurationName);

var configs =new Enumerator (configMgr) ;
for ( ; !configs.atEnd () ; configs.moveNext () ) {
configs.item ().Properties ("StartAction").Value =1 ; //- Need to set it to Start Program
configs.item ().Properties ("StartProgram").Value =strCompleteAcadPath ;
}

//var DebugTool =config.DebugSettings //DebugTool.Command =strAcadPath ;
try {
var newRef =project.Object.References.Add (strAcmgdPath) ;
newRef.CopyLocal =false ;
newRef =project.Object.References.Add (strAcdbmgdPath) ;
newRef.CopyLocal = false;
newRef = project.Object.References.Add(strAcCuiPath);
newRef.CopyLocal = false;
}
catch (e) {
wizard.OkCancelAlert("Failed to add AutoCAD Managed DLL,\nFiles not found in default path.");
}

Value of the strAcadPath variable is calculated by the FindAutoCAD function:

function FindAutoCAD() {
var szVersion = "1";
var szPath = "c:\\Program Files\\AutoCAD";
var acadId = "{5783F2D7-%-%-0102-0060B0CE6BBA}";
var objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2");
var colSoftware = objWMIService.ExecQuery("Select * from Win32_Product Where IdentifyingNumber like '" + acadId + "' AND Vendor = 'Autodesk'");
var enumItems = new Enumerator(colSoftware);
for (; !enumItems.atEnd(); enumItems.moveNext()) {
var objItem = enumItems.item();
if (objItem.Version > szVersion) {
szPath = objItem.InstallLocation;
szVersion = objItem.Version;
}
}
return (szPath);
}

It is easy to see that in FindAutoCAD the starting value of szPath variable is for some reason connected to the path "c:\\Program Files\\AutoCAD".
The simplest way to repair is not to change FindAutoCAD, but to set strAcadPath variable with your own path to AutoCAD 2010 folder and to comment the old version of the line, e.g.:

//var strAcadPath = FindAutoCAD();
var strAcadPath = "D:\\Autodesk\\AutoCAD 2010 Eng-32\\";

Compilation Problems

2. In the files AssemblyInfo.vb and AssemblyInfo.cs the lines
<Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyFileVersion("1.0.*")>
are to be changed to
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
Otherwise you will get compilation error.

3. In AssemblyInfo.vb the following comment lines are given with //, but should have apostroph:
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
//   (*) If no key is specified, the assembly is not signed.
//   (*) KeyName refers to a key that has been installed in the Crypto Service
//       Provider (CSP) on your machine. KeyFile refers to a file which contains
//       a key.
//   (*) If the KeyFile and the KeyName values are both specified, the
//       following processing occurs:
//       (1) If the KeyName can be found in the CSP, that key is used.
//       (2) If the KeyName does not exist and the KeyFile does exist, the key
//           in the KeyFile is installed into the CSP and used.
//   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
//       When specifying the KeyFile, the location of the KeyFile should be
//       relative to the project output directory which is
//       %Project Directory%\obj\. For example, if your KeyFile is
//       located in the project directory, you would specify the AssemblyKeyFile
//       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
//   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
//       documentation for more information on this.
//
Delete these lines or substitute // with apostroph to cancel compilation error.

4. In AssemblyInfo.vb comment the line
<Assembly: Guid("[!output GUID_ASSEMBLY]")>
as GUID is unnecessary for assembly.


NP CAD Page | Articles | Download | Russian