System.MissingFieldException: Field not found: 'Autodesk.AutoCAD.DatabaseServices.BlockTableRecord.ModelSpace'.
What wrong with this code? It work in 2006.
Private Sub ADDPlotstyle(ByVal PS As String)
Dim db As Database = HostApplicationServices.WorkingDatabase()
Dim trans As Transaction = db.TransactionManager.StartTransaction()
Dim docLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument()
Dim btr As BlockTableRecord
Dim bt As BlockTable = trans.GetObject(db.BlockTableId, OpenMode.ForRead)
Dim btrId As ObjectId = bt(btr.ModelSpace)
btr = trans.GetObject(btrId, OpenMode.ForWrite)
Try
Dim center As New Point3d(10, 10, 0)
Dim text As New MText
text.Contents = "Plot Style"
text.Location = center
btr.AppendEntity(text)
text.PlotStyleName = PS
trans.AddNewlyCreatedDBObject(text, True)
text.Erase()
Catch ex As Exception
End Try
docLock.Dispose()
trans.Commit()
trans.Dispose()