<div>Hi, VTK guys,</div><div><br></div><div>I use Activiz VTK 7.0 C# wrapper to develop an application to view DICOM series. However, when vtkResliceCursorWidget is enabled, the application throws access violation exception when the application is closed. What's wrong with my C# code?</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>private void Display(vtkRenderWindow aRenderWindow, vtkImageData aData)</div><div>        {</div><div>            if (aData == null)</div><div>                return;</div><div>            <span style="line-height: 1.5;">m_imageViewer = vtkImageViewer2.New();</span></div><div>            m_imageViewer.SetInputData(aData);</div><div>            m_imageViewer.SetSliceOrientation((int)m_sliceDirection);</div><div>            </div><div>            m_imageViewer.GetSliceRange(ref m_minSliceNumber, ref m_maxSliceNumber);</div><div>            vtkRenderWindowInteractor interactor = aRenderWindow.GetInteractor();</div><div> </div><div>            m_imageViewer.SetupInteractor(interactor);</div><div>            aRenderWindow.GetRenderers().InitTraversal();</div><div>            m_renderer = aRenderWindow.GetRenderers().GetFirstRenderer();</div><div>            m_renderer.SetBackground(0.0, 0.0, 0.0);</div><div><br></div><div>            m_imageViewer.SetRenderWindow(aRenderWindow);</div><div>            m_imageViewer.SetRenderer(m_renderer);</div><div><br></div><div>            m_interactorStyle = m_imageViewer.GetInteractorStyle();</div><div>            m_moveforward = new vtkObject.vtkObjectEventHandler(interactor_MouseWheelForwardEvt);</div><div>            m_movebackward = new vtkObject.vtkObjectEventHandler(interactor_MouseWheelBackwardEvt);</div><div><br></div><div>            m_interactorStyle.MouseWheelForwardEvt += m_moveforward;</div><div>            m_interactorStyle.MouseWheelBackwardEvt += m_movebackward;</div><div><br></div><div>            interactor.SetInteractorStyle(m_interactorStyle);           </div><div>                        </div><div>            m_currentSlice = m_minSliceNumber + (m_maxSliceNumber - m_minSliceNumber) / 2;</div><div>            m_imageViewer.SetSlice(m_currentSlice);</div><div><br></div><div>            m_scalarrange = new double[2];</div><div>            m_scalarrange = m_imageViewer.GetInput().GetScalarRange();</div><div><br></div><div>            if (!m_initialized)</div><div>            {</div><div>                m_threshold = new Segament_Threshold();</div><div>                m_threshold.Min_Threshold = 0;</div><div>                m_threshold.Max_Threshold = m_scalarrange[1];</div><div>            }</div><div><br></div><div>            if (!m_initialized)</div><div>            {</div><div>                m_reslicecursor = vtkResliceCursor.New();</div><div>                m_reslicecursorrep = vtkResliceCursorThickLineRepresentation.New();</div><div>                </div><div>                m_reslicecursorwidget = vtkResliceCursorWidget.New();</div><div>                m_reslicecursorwidget.SetInteractor(interactor);</div><div>                m_reslicecursorwidget.SetDefaultRenderer(m_renderer);</div><div>                m_reslicecursorwidget.SetRepresentation(m_reslicecursorrep);</div><div>            }</div><div><br></div><div>            double[] image_cent = aData.GetCenter();</div><div>            m_reslicecursor.SetCenter(image_cent[0], image_cent[1], image_cent[2]);</div><div>            m_reslicecursor.SetImage(aData);</div><div>            m_reslicecursor.SetThickMode(0);</div><div>            m_reslicecursorrep.GetResliceCursorActor().GetCursorAlgorithm().SetResliceCursor(m_reslicecursor);</div><div>            m_reslicecursorrep.GetResliceCursorActor().GetCursorAlgorithm().SetReslicePlaneNormal((int)m_sliceDirection);</div><div>            m_reslicecursorwidget.SetEnabled(1);</div><div>            m_imageViewer.GetRenderer().ResetCamera();</div><div><br></div><div>            m_imageViewer.Render();</div><div>            m_initialized = true;</div><div>        }</div><div><br></div><div>Thanks</div><div>Liu Peng</div>