You're not showing the actual code, because what you
show would fail at the call to GetObject(), because you're
not casting the result to a LayerTable.
Also, what release of AutoCAD are you using?
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com
wrote in message news:5823542@discussion.autodesk.com...
I am trying to iterate through the layer table and keep getting the following error message:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException: Method not found: 'Autodesk.AutoCAD.DatabaseServices.SymbolTableEnumerator Autodesk.AutoCAD.DatabaseServices.LayerTable.GetEnumerator()'.
at ClassLibrary.STCClass.test()
My code looks like this:
Database db = new Database(false, true);
db.ReadDwgFile(filename, System.IO.FileShare.None, false, null);
Transaction tr = db.TransactionManager.StartTransaction();
LayerTable lt = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForRead);
foreach (ObjectId objID in lt)
{
.
.
.
}
If I comment our the foreach the error goes away.
What am I doing wrong?
Thanks,
lt.Close();
tr.Commit();
db.Dispose();