Recently spotted some code on web about aborting transactions when exceptions occur. It is in VB.NET. Here is a cleaned up version.
Dim tr As Transaction = db.TransactionManager.StartTransaction
Dim obj As Object = tr.GetObject(id, OpenMode.ForRead, False, False)
Catch ex As ApplicationException
The writer only aborts the ‘tr’ Transaction when the ApplicationException occurs. What about other kind of exceptions such as System.AggregateException, System.SystemException and many more that are also parallel to the System.ApplicationException in the System.Exception hierarchy tree?
It seems replacing the ApplicationException with the System.Exception is the fix. However, if she understood why the tr.Dispose() call is there in the Finally block, the tr.Abort() call would have been removed. As analyzed and demonstrated many times before, using the using statement for transactions is a good AutoCAD .NET coding practice in both C# and VB.NET.
The leading edge AutoCAD .NET Addin Wizard (AcadNetAddinWizard) provides various project wizards, item wizards, coders and widgets to help program AutoCAD .NET addins.