>> The book "VB.NET Programming for AutoCAD Customization" by Jerry Winters is where I learned to dispose of the Transaction Manager... it was in every piece of sample code he had pretty much. I don't know whether that means it's right or wrong, I'm just citing where I got that idea. <<
Sorry to have to say it, but Jerry Winters has never written a single line of C++/Native ObjectARX code, and barely understands the underlying ObjectARX API. In case anyone didn't notice, this isn't about the VB.NET programming language, this is about the ObjectARX API.
The TransactionManager object wraps an instance of the native AcDbTransactionManager class, and there is one and only one instance of it for each AcDbDatabase, and that instance cannot/should not be destroyed by any consumer that uses it.
In this case, you didn't create the TransactionManager, you only obtained a reference to it via the TransactionManager property of the Database. Hence, you do not 'own' it, nor are you responsible for managing its lifetime (the owning Database is), so even though it incorrectly has a Dispose method (yes, that is a design flaw - see below), you should never call it.
The reason that many API objects support IDisposable and have Dispose() methods, is largely coincidental, by way of the fact that they derive from a base type called 'DisposableWrapper'. DisposableWrapper provides a generic means of implementing a managed type that 'wraps' a native object (which could be just about anything).
In some cases, when a DisposableWrapper-based type is garbage collected (either because its Dispose() method was called, or because it is no longer referenced and the garbage collector reclaimed it), the underlying or 'wrapped' native object is also destroyed, usually because the consumer that is using the DisposableWrapper-based type also owns it, and is responsible for managing its lifetime. An example of that, is when you create a new DBObject-based type, but do not add it to a Database. In that case, you own that object and you are responsible for managing its life, and so you must destroy it when you're done using it, and that's done by calling its Dispose() method.
In other cases (like TransactionManager) the underlying native object is not destroyed when the wrapper is, because the native object is 'shared' by many consumers and its lifetime is tied to and/or managed by another 'owner' object, which in the case of TransactionManager, is the owning Database. So, it is Autodesk's generic and widespread re-use of the DisposableWrapper type that is the source of the confusion for many.
Personally, I view the fact that Autodesk used this base type even when the object should not be disposed by consumers, and/or when the implementation of Dispose() does absolutely nothing, as horrendously poor API design, and one of the major contributing factors of the confusion surrounding the Dispose() method and its use, that so many new .NET programmers and learners (like Jerry Winters) experience, a fact that is clearly evidenced by just reading this newsgroup.
The bottom line with regards to the debug messages that you see, is that if the message is displayed for a DBObject that you obtained from a transaction, the message is itself bogus, and you can safely ignore it. That's because you can safely avoid calling Dispose() on any DBObject that you obtained from a Transaction.
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2009
Supporting AutoCAD 2000 through 2009
http://www.acadxtabs.com
Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm
wrote in message news:5960259@discussion.autodesk.com...
A lot of the disposals were added after I encountered this problem; most of the time I was just disposing of myDB (in setlay), myTrans and myTransMan.
I originally called setlay 4 times in my test sub... when I did that, I would get 6 of those errors after running, then 2 more when AutoCAD was closed. It seems like the errors are thrown whenever the inserted layer, which immediately became active, lost focus and was no longer the active layer. Maybe I'm missing something when I switch active layers?
The other thing that I find especially vexing is that I didn't have this problem until I involved the Access db and the lt.lin file... and even though I keep getting this problem every time, the order in which I receive these warnings is always changing.
Thanks for your time in this matter, it is very much appreciated.