I have written the following code snipt to reload one dwg xref, an exception is thrown when reloading. I don't know any better way to implement this function, I appreciate very much if you could provide me any suggestion, comment or idea. Thanks a lot
Code:
AcadDatabase acadDB = null;
Database db = new Database();
XrefGraph Xref = null;
XrefGraphNode XrefNode = null;
Transaction trans = null;
BlockTable Btable = null;
BlockTableRecord BTrecord = null;
try
{
db.ReadDwgFile(@"C:\MEP\All.dwg", FileShare.ReadWrite, false, "");
Xref = db.GetHostDwgXrefGraph(true);
acadDB = db.AcadDatabase as AcadDatabase;
for (int k = 1; k < Xref.NumNodes; k++)
{
trans = db.TransactionManager.StartTransaction();
XrefNode = Xref.GetXrefNode(k);
try
{
acadDB.Blocks.Item(XrefNode.Name).Reload();
}
catch (System.Exception e)
{
// an exception is thrown here, it said that:" Catastrophic failure(Exception is form HRESULT:0x8000FFFF (E_UNEXPECTED))
}
trans.Commit();
trans.Dispose();
}
db.Save();
}
finally
{
db.CloseInput(true);
}