I'm thinking this is by design, but a generic Fatal Error: Access Violation exception (which cannot be caught) is thrown and causes autocad to crash whenever I attempt to pass an instance of Document or Database to another classes method (a class other than the one which implements IApplicationExtension).
I've had trouble confirming this is by design and is something I just have to work around because AutoDesk restricts this using reflection or by some other means I do not comprehend.
Specifically, I have subscribed to the DocumentManager's DocumentCreated event and I am attempting to pass the instance of the created document provided in the event argument object to an instance of a class I have defined which works with the Document's database but does not perminantly store a reference to the given Document object.
I'm using AutoCAD 2011 64-bit.
Thanks for any help in advance.
Solved! Go to Solution.
I don't think the errors you are receiving are by design, I regularly use the passing of Document arguments to cut up large functions into more managable methods. As long as you do not store the variable in a field you should be fine.
Do you develop in C# or VB? C# by default passes the argument as a reference to the actual data (VB ByRef) where VB's ByValue might cause an access violation because of the called function trying to copy the data.
I did try your solution, and I thank you for the suggestion. However, passing by reference did not fix this issue.
As a side note I am using vb.net (not my choice, my employers :'). After some trial and error I was able to solve the problem. I believe the problem was that the class I was passing the instance of Document to was derived from CollectionBase. I created a test class which was not derived from CollectionBase and the problem went away. So perhaps this was by design and the authors of this API were using reflection to prevent instances of certain types from being added to a collection.
Thanks again for your help.