PPT_LOGO_4b
‹#›
© 2009 Autodesk
Autodesk Developer Network
Resolving Naming Ambiguities
§At the beginning of each file:
§
§
§
§
§
§
§
§
§
§
§
§In VB, pure Imports can be defined via properties on project level, but not Imports xxx = yyy.zzz statements
Imports System.Windows.Forms
' ...
' AutoCAD
Imports Autodesk.AutoCAD.DatabaseServices
' ...
' ACA (Aec)
Imports Autodesk.Aec.DatabaseServices
' ...
' To resolve Object/Entity ambiguities
Imports AcObject = Autodesk.AutoCAD.DatabaseServices.DBObject
Imports AecObject = Autodesk.Aec.DatabaseServices.DBObject
Imports AcEntity = Autodesk.AutoCAD.DatabaseServices.Entity
Imports AecEntity = Autodesk.Aec.DatabaseServices.Entity
' To resolve Application ambiguities with System.Windows.Forms
Imports AcadApp = Autodesk.AutoCAD.ApplicationServices.Application
The .NET API provides all its objects under namespace hierarchies. By default, an object is qualified in the current scope if the namespace is imported. Because everything is qualified under a namespace, you will find cases where objects may have the same name, but live under different namespaces. This will confuse the standard qualification because the compiler cannot determine which object you are specifically referring to. Fortunately both C# and VB.NET languages provide an alias mechanism to make it easier to qualify the namespaces appropriately when necessary.
For example, there is a different object named DBObject in both ACA and AutoCAD .NET APIs. You will see an ambiguous reference error when trying to use this type in a typical way. The reason for this is because the object lives in both the Autodesk.AutoCAD.DatabaseServices and Autodesk.Aec.DatabaseServices namespaces. In order to resolve the ambiguity, you must clarify the namespace of the version you are intending to use.

At Object level:
using AcDBObject = Autodesk.AutoCAD.DatabaseServices.DBObject;
using AecDBObject = Autodesk.Aec.DatabaseServices.DBObject;
...
AecDBObject obj = new AecDBObject();

Or at the namespace level:
using AcDb = Autodesk.AutoCAD.DatabaseServices; // AutoCAD database objects
using AecDb = Autodesk.Aec.DatabaseServices; // ACA Base classes
...
AecDb.DBObject obj = new AecDb.DBObject();