System.MissingMethodException

System.MissingMethodException

Anonymous
Not applicable
1,118 Views
7 Replies
Message 1 of 8

System.MissingMethodException

Anonymous
Not applicable
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();
0 Likes
1,119 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
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();
0 Likes
Message 3 of 8

Anonymous
Not applicable
Looks like a c style cast to me ??
0 Likes
Message 4 of 8

Anonymous
Not applicable
Hi Dan, you're right, I missed it 🙂

But, there is still something fishy because it works fine here.

And that's why I don't think he's showing the actual code.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5823985@discussion.autodesk.com...
Looks like a c style cast to me ??
0 Likes
Message 5 of 8

Anonymous
Not applicable
That is the actual code. I only left out the lines inside the foreach loop. Could the C-style cast be the problem?

I'm using VS 2005 and AutoCAD 2006.

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)
{
.
.
.
}

lt.Close();

tr.Commit();
db.Dispose();
0 Likes
Message 6 of 8

Anonymous
Not applicable
Works in AutoCAD 2007.
0 Likes
Message 7 of 8

Anonymous
Not applicable
You are referencing wrong versions of the
managed assemblies for AutoCAD 2006.

If you're thinking that you can use the same
.NET dll in both of those releases, you can't,

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

wrote in message news:5824195@discussion.autodesk.com...
Works in AutoCAD 2007.
0 Likes
Message 8 of 8

Anonymous
Not applicable
No... I just need it to work in one or the other.
Thanks for the heads-up though.
0 Likes