To narrow down the issue, I found ResolveXrefs method will throw an UriFormatException under some circumstances. Is there anyone who know why this exception was thrown? And what is the proper way of handling?
I add several event handler to current database, and found during the execution of ResolveXrefs method, there are at least four events fired. They are XrefBeginAttached, XrefRedirected, XrefBeginOtherAttached and XrefAttachEnded. Seems the last event will be triggered only when all the xrefs have been handled (although there still exists unresolved xrefs). To my problem, the UriFormatException was fired after callback for XrefBeginOtherAttached is triggered. I think when the exception was thrown, there are something that need to be disposed, but unfortunately, I have no idea what should be disposed. And this should be the reason why RuntimeSystem.Terminate() failed with AV exception.
I would appreciate if anyone can give me some help. Many thanks!