[Insight-users] AccessViolationException in ManagedITK

Volodymyr Tkachuk vova.tkachuk at gmail.com
Mon Oct 18 10:04:20 EDT 2010


Simply following code:
try
            {

                var image = itkImage_UC2.New();
                image.Read("input.tif");
                var filter = itkComposeRGBImageFilter_IUC2IRGBUC2.New();
                filter.SetInput1(image);
                filter.SetInput2(image);
                filter.SetInput3(image);

                filter.Update();
                var res = itkImage_RGBUC2.New();
                filter.GetOutput(res);

                res.Write("output.tif");
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
            }
Error message is: Unhandled Exception: System.AccessViolationException:
Attempted to read or write
 protected memory. This is often an indication that other memory is corrupt.
   at itk.ComposeRGBImageFilter<itk::Image<unsigned
char,2>,itk::Image<itk::RGBP
ixel<unsigned char>,2> >.{dtor}(ComposeRGBImageFilter<itk::Image<unsigned
char\,
2>\,itk::Image<itk::RGBPixel<unsigned char>\,2> >* )
   at itk.ComposeRGBImageFilter<itk::Image<unsigned
char,2>,itk::Image<itk::RGBP
ixel<unsigned char>,2>
>.__vecDelDtor(ComposeRGBImageFilter<itk::Image<unsigned
char\,2>\,itk::Image<itk::RGBPixel<unsigned char>\,2> >* , UInt32 )
   at itk.Object.RemoveAllObservers(Object* )
   at itk.itkObjectAutoPtr<itk::ComposeRGBImageFilter<itk::Image<unsigned
char\,
2>\,itk::Image<itk::RGBPixel<unsigned char>\,2> >
>.Reset(ComposeRGBImageFilter<
itk::Image<unsigned char\,2>\,itk::Image<itk::RGBPixel<unsigned char>\,2> >*
ptr
)
   at itk.itkComposeRGBImageFilter_IUC2IRGBUC2.Dispose(Boolean )
   at itk.itkComposeRGBImageFilter_IUC2IRGBUC2.Dispose()
   at itk.itkComposeRGBImageFilter_IUC2IRGBUC2.Dispose(Boolean )

When I use "using" block for filter class like this:
 try
            {

                var image = itkImage_UC2.New();
                var res = itkImage_RGBUC2.New();
                image.Read("input.tif");
                using (var filter =
itkComposeRGBImageFilter_IUC2IRGBUC2.New())
                {
                    filter.SetInput1(image);
                    filter.SetInput2(image);
                    filter.SetInput3(image);

                    filter.Update();
                    
                    filter.GetOutput(res);
                }
                res.Write("output.tif");
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
            }

Exception does not occure.

I'm using VS2010 ManagedITK and the project compiled for x64 platform with
.Net 4.
-- 
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/AccessViolationException-in-ManagedITK-tp5646651p5647129.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list