Trying to save an image in VS C# exits with code -2147483645 (0x80000003)

0

so I'm trying to save an image via this code:

SaveFileDialog saveFileDialogThing = new SaveFileDialog();
Bitmap test = new Bitmap(5, 5);
//Do some image edit thingies
  try
  {
    if(saveFileDialogThing.ShowDialog() == DialogResult.OK){
    test.Save(saveFileDialogThing.FileName);
    }
  }
catch (Exception ex) { Console.WriteLine(ex.ToString()); }

When running in Debug configuration, everything works as intended. However, when running in Release configuration, it doesn't save the file and instead crashes with The program '[19656] Cool Program.exe' has exited with code -2147483645 (0x80000003)., without even catching whatever exception may be causing this, if any. What gives?

This also happens when trying to open an image like so:

Bitmap imgIn;
OpenFileDialog openFileDialogTest = new OpenFileDialog();

openFileDialogTest.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
openFileDialogTest.Filter = "Image files (*.png)|*.png";
openFileDialogTest.FilterIndex = 2;
openFileDialogTest.RestoreDirectory = true;
  if (openFileDialogTest.ShowDialog() == DialogResult.OK)
  {
    filePath = openFileDialogTest.FileName;
    imgIn = new Bitmap(filePath);
  }

Can anyone help me with this?

Regards,

radzo73

c#
asked on Stack Overflow Feb 5, 2021 by Conrad Falloff • edited Feb 5, 2021 by Conrad Falloff

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0