Dynamo for Civil exception

Sorry if I wrote the wrong section…
I cached a very bad exception when Civil 3D closing:

Exception thrown: ‘System.AccessViolationException’ in LibG.Managed.dll
An unhandled exception of type ‘System.AccessViolationException’ occurred in LibG.Managed.dll
Attempting to read or write protected memory. This often indicates that the other memory is damaged.

Screencast: https://autode.sk/31qqH5I
How can this be caused and what are the consequences?

No real consequences AFAIK - but this should no longer happen in later versions of the geometry library. (2.2) and up I believe. (yet to be released).

In this case, it’s not your code and only happens at shutdown - if you see it in other cases you may not be disposing geometry correctly: see this:

1 Like

Yes, it’s only when Civil 3D closing, without my code! I tested sample code from help: https://knowledge.autodesk.com/support/civil-3d/learn-explore/caas/CloudHelp/cloudhelp/2020/ENU/Civil3D-UserGuide/files/GUID-D1886821-9FE2-4431-9BC4-9147F85B91A3-htm.html
Now I am calm!
Thanks for quick reply!
P.S. Oh, I have to call dispose() for points! This is very unexpected! I’m used to the fact that in AutoCAD, points (Point2d, Point3d) have a value type …

Hi @DmitriyZagorulkin - I would advise disposing everything (this issue has less to do with a memory leak, and more with threading issues) - I cannot promise anything of course, but we are looking at making these dispose calls less important.

1 Like

You can dispose anything except any transaction:

I think, you don’t have to dispose AutoCAD database objects when they open with transaction (with method Transaction.GetObject). The transaction itself closes these objects. However, if you use “using” external block, there will be no error. But it is not necessary.
Also, you don’t have to call Transaction.Commit() method.
P.S. Yes, i found call Commit() inside AcDynamoServices.dll. But there are no call Dispose() for Transaction, only for DocumentLock… It’s very strange…

@Michael_Kirschner2, сould it be that this exception is the result of the absence of the Transaction.Dispose () method in AcDynamoServices.dll?

I am referring to disposing Dynamo protogeometry objects - guess I should not have said everything :wink:

1 Like

Ok, ok! No problems! I believe that you will fix all errors! The main thing for me is that you know about them. :innocent: