Acccording to documentation from AutoCAD’s .NET reference, they are overriding the Using Statement, but not Dispose(). How is this even possible?

Quote from documentation here.

If you make changes to an object after you opened it with the Open method, you can use the Cancel method to rollback all the changes made since it was opened. Cancel must be called on each object in which you want to rollback. Objects must also be properly disposed of with the Dispose method after an object is closed or you can use the Using statement to close and dispose of an object.

That last line is concerning me because it implies that they somehow have implementation that executes close() on an object at the end of a using block, but not when you call Dispose(). I’m almost positive that all Using does is call Dispose() on an object before it leaves scope, so I don’t see H O W this is even possible. So one of two things is true here:

  1. I am wrong, and there is indeed a way to have Using dispose of an object via a different process then calling Dispose() does.
  2. The documentation person responsible for this article is just completely incorrect here. Trust me, past experiences have shown that this is not impossible with them.


Edit 1: Decompiling helps nothing, most .NET calls in their API are just wrapped calls to an unmanaged library.

Edit 2: I’m not exactly sure of a simple way to test this, just wanted to see if the community had any thoughts before I do.

Edit 3: They go on to say

Note: Objects must be paired with an open and close operation. If you use the Open method without the Using statement, you must call either the Close or Cancel method on an opened object. Failure to close an object will lead to read access violations and cause AutoCAD to become unstable.

submitted by /u/CrockettScience
[link] [comments]

Leave a Reply