[Insight-users] AccessViolationException in ManagedITK

Dan Mueller dan.muel at gmail.com
Mon Oct 18 13:30:52 EDT 2010


Hi Volodymyr,

I am having trouble reproducing the issue you reported.

I downloaded and installed Visual Studio C# 2010 Express (with .NET
4.0). Your program ran as expected without exception using the
pre-compiled ManagedITK assemblies built against ITK 3.20 x86
available at the Google Code page... (Though I did have to add an
app.config file with useLegacyV2RuntimeActivationPolicy=true to even
get the program to run).

What version of ManagedITK assemblies are you using? Pre-compiled
assemblies or did you compile them yourself? Perhaps it is a x64
issue...?

Cheers, Dan

On 18 October 2010 16:04, Volodymyr Tkachuk <vova.tkachuk at gmail.com> wrote:
>
> 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


More information about the Insight-users mailing list