.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

AccessViolationException after closing 2014

1 REPLY 1
Reply
Message 1 of 2
dmmusil
390 Views, 1 Reply

AccessViolationException after closing 2014

Hi all,

 

I am getting an AccessViolationException after closing AutoCAD 2014 with my addin installed.  I have been able to debug the Terminate() function and can see that my code completes without throwing an uncaught exception.  The stack trace for the error is below.

 

at AcDiObservableCollection.removeReactor(AcDiObservableCollection* , AcDiCollectionReactor* )
at Autodesk.AutoCAD.Windows.Data.DataItemCollection.!DataItemCollection()
at Autodesk.AutoCAD.Windows.Data.DataItemCollection.Dispose(Boolean )
at Autodesk.AutoCAD.Windows.Data.DataItemCollection.Finalize()

 

I've spent the last few days reading about how and when to dispose of unmanaged DBObjects and have placed using statements and calls to Dispose() everywhere I can find that they are required.  The error is thrown whether I perform some workflow with the addin or just open AutoCAD and close it immediately.  Occasionally the error will not be thrown, even though I've performed the same actions as a time when it was thrown.  That makes me think it's just the GC attempting to work a little sooner than the times when the exception happens.  The addin creates a menu via .cuix file, as well as adds a ribbon tab to the AutoCAD menu.  A control pallette is also loaded to allow for further actions. 

 

Is this likely related to the usual disposal problem or is it possible that it is something else?  Do I need to implement IDisposable in the objects that I create and use over the course of the workflow or is it enough to only use Dispose() on unmanaged wrappers?  Does the fact that the stack trace contains the Windows namespace mean that it's UI related?

 

Occasionally I get a different exception after leaving the managed .NET code.  It is an SEHException and the stack trace is below.

 

at __RTDynamicCast(Void* , Int32 , Void* , Void* , Int32 )
at Autodesk.AutoCAD.Windows.Data.DataItemContext.!DataItemContext()
at Autodesk.AutoCAD.Windows.Data.DataItemContext.Dispose(Boolean )
at Autodesk.AutoCAD.Windows.Data.DynamicObjectBase.Finalize()

 

Any ideas are much appreciated.

 

Dylan

1 REPLY 1
Message 2 of 2
fenton.webb
in reply to: dmmusil

best thing to do is first prove that it has something to do with your dispose'ing. The main issue with any non-disposing is that any .NET garbage collection is done on a different thread to AutoCAD's main thread, and AutoCAD doesn't like that in some circumstances. So, configuring .NET GC to run on the main thread will wipe any potential dispose issues from the equation - here's how to do that http://adndevblog.typepad.com/autocad/2012/07/forcing-the-gc-to-run-on-the-main-thread.html

 

If your code still crashes after this, then it's got nothing to do with dispose, but something else in your code. If it doesn't crash anymore, then you need to look more carefully at your dispose calls.




Fenton Webb
AutoCAD Engineering
Autodesk

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost