AccessViolationException when exit

My .net WPF application use Activiz.net 5.8, and sometimes will get an exception on exit.

System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Kitware.VTK.vtkObjectBase.vtkObjectBase_UnRegister_12(HandleRef pThis, HandleRef o)
at Kitware.VTK.vtkObjectBase.Dispose(Boolean disposing)
at Kitware.VTK.vtkOpenGLRenderer.Dispose(Boolean disposing)
at Kitware.mummy.Runtime.WrappedObject.Finalize()

This exception happens very rarely, usually when it runs for a long time (several hours) and exits.
How to find the cause of this excepton?

@mwestphal

@LucasGandel @lgivord

@liuzhongshu Activiz 5.8 is very old, I’m not sure you will find much help with it.

maybe @alexy.pellegrini may have an idea :thinking:

You might want to check if this still happens with the latest version by requesting a trial version on the Activiz website.

Disposing the renderer and other VTK objects on the WindowsFormHost “closing” event (or any other event triggered before the exception) might also help.

@LucasGandel Thanks, I tried Dispose, but the problem still exists.

I will try using a new trial version to compare, but my code is old, I need to modify the code first to be compatible with the new version.