The following method throws this exception
System.IO.Stream)(ms)).ReadTimeout threw an exception of type System.InvalidOperationException'
This is the method:
private static byte[] ImageToByteArraybyMemoryStream(Bitmap bmp)
{
using (MemoryStream ms = new MemoryStream()) {
bmp.Save(ms, bmp.RawFormat);
return ms.ToArray();
}
}
however, this error doesn't occur all the time. I'll try to explain in short what happens:
- I load a bitmap from a file, display it and store it in
Dictionary<int,Bitmap>
- When application is closed, i write bitmap to apps config-file as
byte[]
(and there's no exception) - On start of app i load bitmap from config-file and display it
- When user changes application-data (like resizing or moving the bitmap) i rewrite the config-file the same way as i did when bitmap was loaded from file and this exception occurs.