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

AccessViolationException

4 REPLIES 4
Reply
Message 1 of 5
dwi_it
1286 Views, 4 Replies

AccessViolationException

 AccessViolationException:Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

 

This question has been posted several times and there isn't really a clear answer. (Its a hard question, I know) I get this error in my addin every once in a while. No specific line of code, and my addin is pretty big and does a lot of different stuff, so I can't really tell if its anythign I'm doing. I've been through the code alot and I know I'm not missing any .Dispose calls. (Usually I get a nice message in the debug output "forgot to call dispose?" if I did miss one)

 

If you have any suggestions for a fix, they are welcome. My real question is, can I legitematly tell my Manager and Users that this is a issue with AutoCAD and that there is nothing I can do about it?

4 REPLIES 4
Message 2 of 5
fieldguy
in reply to: dwi_it

I have seen this and for me it was fixed by adding document locks around transactions.  This occurs in several discussions as well and has some relation to using modeless forms.

Message 3 of 5
chiefbraincloud
in reply to: dwi_it

Unfortunately I would have to say no.  The problem is most likely in your code somewhere.  I have personally never gotten that specific error without being able to track down where it was my fault and eliminate it.  And it is probably not the result of forgetting to call dispose.

 

The fact is, you are probably getting the error at some point in the code where you have called dispose, or the object was automatically disposed by a Using statement, and then you tried to access the object.  Actually, you wouldn't even have to have called dispose, and could still be inside the Using statement, but after you commit or abort the transaction, no objects associated with the transaction can be used (except to call dispose).

 

Dave O.                                                                  Sig-Logos32.png
Message 4 of 5
dwi_it
in reply to: chiefbraincloud

Part of this issue is that it doesn't happen consitently. In one case my code was re-building some block definitions (my program is a rule based drawing system), where I was calling the same function in a long running loop. It ran through most then threw the error (maybee halfway through a list of 200). So my assumption would be that if I was accessing a disposed object or objects in a closed transaction, it would happen the first time every time, correct? Plus, my couple users are using these functions to insert our products into drawings, so they are hitting this code all day long, and very rarely getting the error (two occurences this week, and the one happend to me while testing). So I'm at a loss of what to look for.

 

I agree its probably not a missed dispose, in my experiences where I know I've forgotten to dispose of an object, AutoCAD usually just crashes and exists with no .NET exceptions.

 

It hasnt' happened alot but the few stack traces I have don't show anything in common. I've include a the tops of a few of the stack traces below, in case they might spark some insight (I only included the AutoCAD portions).

 

 

 at Autodesk.AutoCAD.ApplicationServices.TransactionManager.FlushGraphics()
   at Autodesk.AutoCAD.ApplicationServices.AppTransaction.Commit()
   ------------------------------------------------------------------------------------------------------------
      at AcDbSpline.{ctor}(AcDbSpline* , Int32 , Int32 , Int32 , Int32 , AcArray<AcGePoint3d\,AcArrayMemCopyReallocator<AcGePoint3d> >* , AcArray<double\,AcArrayMemCopyReallocator<double> >* , AcArray<double\,AcArrayMemCopyReallocator<double> >* , Double , Double )
   at Autodesk.AutoCAD.DatabaseServices.Spline..ctor(Int32 degree, Boolean rational, Boolean closed, Boolean periodic, Point3dCollection controlPoints, DoubleCollection knots, DoubleCollection weights, Double controlPointTolerance, Double knotTolerance)

------------------------------------------------------------------------------------------------------------   
   at Autodesk.AutoCAD.DatabaseServices.Transaction.DeleteUnmanagedObject()
   at Autodesk.AutoCAD.Runtime.DisposableWrapper.!DisposableWrapper()
   at Autodesk.AutoCAD.Runtime.DisposableWrapper.Dispose(Boolean )
   at Autodesk.AutoCAD.Runtime.DisposableWrapper.Dispose()

------------------------------------------------------------------------------------------------------------   
 at AcEdJig.drag(AcEdJig* )
   at Autodesk.AutoCAD.EditorInput.Jig.DoIt()
   at Autodesk.AutoCAD.EditorInput.Editor.Drag(Jig jig)

Message 5 of 5
chiefbraincloud
in reply to: dwi_it

Unfortunately that is not going to help much. 

 

The error is most likely in the last line of the stack trace (going from bottom to top) that is from your code.  And since you say it is inconsistant, you should be looking for places in the code that aren't frequently hit.

 

Since you are showing four different stacks, it does appear that there are four separate issues.

 

If you are unwilling to, or restricted from providing some code, we won't be able to help much more than that.

Dave O.                                                                  Sig-Logos32.png

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