# when program run reader-\>update,vs throws a microsoft c++ error

**URL:** https://discourse.itk.org/t/when-program-run-reader-update-vs-throws-a-microsoft-c-error/4744
**Category:** Beginner Questions
**Tags:** c
**Created:** [January 21, 2022, 5:35am UTC](https://discourse.itk.org/t/when-program-run-reader-update-vs-throws-a-microsoft-c-error/4744 "2022-01-21T05:35:44Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Bugmaker](https://discourse.itk.org/user_avatar/discourse.itk.org/bugmaker/32/2500_2.png) [@Bugmaker](https://discourse.itk.org/u/Bugmaker)
#### Post date: [January 21, 2022, 5:35am UTC](https://discourse.itk.org/t/when-program-run-reader-update-vs-throws-a-microsoft-c-error/4744/1 "2022-01-21T05:35:44Z")

</div>

i want to load a ‘nii.gz’ 3d file , but when program pass reader-\>update() ,vs2017 will give me a microsoft c++ error  
: _Microsoft C++ 异常: itk::ImageFileReaderException，位于内存位置 0x00000000002CF0F8 处。_  
here is my code

```auto
using PixelType = float;
constexpr unsigned int Dimension = 3;
const char* im_path = "C:/Users/Administrator/Desktop/test.nii.gz";
using ImageType = itk::Image<PixelType, Dimension>;
using ReaderType = itk::ImageFileReader<ImageType>;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(im_path);
std::string s = reader->GetFileName();
std::cout << s << std::endl;
ImageType::Pointer image = reader->GetOutput();
reader->Update();

```

---

<div class="post-metadata">

### Author: ![phcerdan](https://discourse.itk.org/user_avatar/discourse.itk.org/phcerdan/32/286_2.png) [@phcerdan](https://discourse.itk.org/u/phcerdan)
#### Post date: [January 21, 2022, 5:38pm UTC](https://discourse.itk.org/t/when-program-run-reader-update-vs-throws-a-microsoft-c-error/4744/2 "2022-01-21T17:38:56Z")

</div>

Welcome @Bugmaker, `reader->Update()` has to be before `reader->GetOutput()`.

Check the examples: [https://itk.org/ITKExamples/src/IO/ImageBase/ReadAnImage/Documentation.html](https://itk.org/ITKExamples/src/IO/ImageBase/ReadAnImage/Documentation.html)
