问题现象
谷歌 百度关键字【 Kitware.VTK.dll “System.AccessViolationException”】
【“System.AccessViolationException”类型的未经处理的异常在 Kitware.VTK.dll 中发生
尝试读取或写入受保护的内存。这通常指示其他内存已损坏】
均未发现解决对策
此问题困扰1周以上
始终不能解决
报错的log
“System.AccessViolationException”类型的未经处理的异常在 Kitware.VTK.dll 中发生
尝试读取或写入受保护的内存。这通常指示其他内存已损坏。
无意间参考vtk9.2官方例子
activizdotnet-master\RenderWindowControl\RenderWindowControl.cs
发现官方版本,在关闭前释放vkt资源,代码如下
protected override void DeleteAllVTKObjects(System.EventArgs e)
{
if (this.m_Renderer != null)
{
this.m_Renderer.SetRenderWindow(null);
}
if (this.m_RenderWindowInteractor != null)
{
this.m_RenderWindowInteractor.Dispose();