I have some code written for 2008 and it works fine to get a list of the Xref's in a drawing. Using the same code in 2010, I get an error on the "Dim btr As BlockTableRecord" line.
The message I get is
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
Has anyone else experience this and if so, is there a away around it?
Dim Doc As Document = AcApp.DocumentManager.MdiActiveDocument
Dim Ed As Editor = Doc.Editor
Dim Db As Database = Doc.Database
Dim Tr As Transaction = Db.TransactionManager.StartTransaction()
Using Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument
Using Tr
Try
Dim DbXrGraph As XrefGraph = Db.GetHostDwgXrefGraph(True)
For i As Integer = 1 To DbXrGraph.NumNodes - 1
Dim XrGraphNode As XrefGraphNode = DbXrGraph.GetXrefNode(i)
If Not XrGraphNode.IsNested Then
Dim btr As BlockTableRecord = DirectCast(Tr.GetObject(XrGraphNode.BlockTableRecordId, OpenMode.ForRead), BlockTableRecord)
If btr.Name = Something Then
End If
End If
Next
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Using
End Using
Thanks in advance
Brent