rafal,
Hmmm....I remember seeing this error also at one point, but for the life of me I can't quite remember how I fixed it. But you could try something like this.....
For VB.Net 2003......
[code]
Public Shared Sub OnObjectModified(ByVal sender As System.Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.ObjectEventArgs)
If TypeOf sender Is Database Then 'Only try to cast a Database object
Try
Dim db As Database = DirectCast(sender, Database)
Try
Dim trans As Transaction = db.TransactionManager.StartTransaction
Try
' if object is BlockReference and it's MyBlock -> update attributes
trans.Commit() 'Commit if no error
Catch ex As Exception
trans.Abort() 'Abort if there is an error
Finally
trans.Dispose()
End Try
Finally
db.Dispose()
End Try
Catch ex As Exception
Debug.WriteLine(String.Format("Unhandled exception: {0}", ex.ToString))
End Try
Else
Debug.WriteLine(String.Format("OnObjectModified Unhandled Type: {0}", TypeName(sender).ToString))
End If
End Sub
[/code]
For VB.net 2005.......
[code]
Public Shared Sub OnObjectModified(ByVal sender As System.Object, ByVal e As Autodesk.AutoCAD.DatabaseServices.ObjectEventArgs)
If TypeOf sender Is Database Then 'Only try to cast a Database object
'If trycast fails, db will be nothing
Dim db As Database = TryCast(sender, Database)
If db IsNot Nothing Then
Try
''Using' construct calls object.dispose automatically
Using trans As Transaction = db.TransactionManager.StartTransaction
Try
' if object is BlockReference and it's MyBlock -> update attributes
trans.Commit() 'Commit if no error
Catch ex As Exception
trans.Abort() 'Abort if there is an error
End Try
End Using
Finally
db.Dispose()
End Try
End If
Else
Debug.WriteLine(String.Format("OnObjectModified Unhandled Type: {0}", TypeName(sender).ToString))
End If
End Sub
[/code]
Good Luck,
C