.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

System.MissingMethodException

7 REPLIES 7
Reply
Message 1 of 8
jprisbe
651 Views, 7 Replies

System.MissingMethodException

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();
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: jprisbe

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();
Message 3 of 8
dmarcotte4
in reply to: jprisbe

Looks like a c style cast to me ??
Message 4 of 8
Anonymous
in reply to: jprisbe

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 ??
Message 5 of 8
jprisbe
in reply to: jprisbe

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();
Message 6 of 8
jprisbe
in reply to: jprisbe

Works in AutoCAD 2007.
Message 7 of 8
Anonymous
in reply to: jprisbe

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.
Message 8 of 8
jprisbe
in reply to: jprisbe

No... I just need it to work in one or the other.
Thanks for the heads-up though.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost