The "Close()" method in the ObjectOverrule, as we know, is called when the overruled DBObject is closed after being opened for reading/writing. Well, it sounds so obvious: first opened, then closed. However, we all write code countless times like this:
using (Transaction tran=myDb.TransactionManager,StartTransaction())
{
Entity ent1=tran.GetObject(entId1, OpenMode.ForRead) As Entity;
//Do something
Entity ent2=tran.GetObject(entId2, OpenMode.ForWrite) As Entity;
//Do something
......
tran.Commit();
}
One would notice that our code only opens object (for reading/writing), but never bothers to close it. The tran.Commit() closes all the open objects. That is, the objects are only closed when the Transaction is committed: this is when the Close() method in the ObjectOverule is called. So, this this moment, the current transaction has been commited (or is committing, maybe?), therefore it is not available any more (even it is still committing, it is on its way out, so it makes sense being not available).
So, even the DBObject in the ObjectOverrule's Close() method is still open before base.Close() is called, the Transaction that governs the DBObject has already gone out of reach.
So, in your case, if you need get other information via transaction, you need to start your own transaction. Here is my quick sample code (where when an DBText is closing, I want to get some information on the DBText's TextStyle, therefore I need to open the TextStyle object in the overridden Close() method):
public override void Close(DBObject dbObject)
{
Document dwg = Application.DocumentManager.MdiActiveDocument;
Editor ed = dwg.Editor;
Database db = dbObject.Database;
DBText txt = dbObject as DBText;
//We need to start a new transaction to open other object, when needed
using (Transaction tran = db.TransactionManager.StartTransaction())
{
TextStyleTableRecord style = (TextStyleTableRecord)
db.TransactionManager.GetObject(txt.TextStyleId, OpenMode.ForRead);
ed.WriteMessage("\nText Style: {0}", style.TextSize.ToString());
tran.Commit();
}
base.Close(dbObject);
}