-
-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ObjectDisposedException in Finish() #22
Comments
This ocurred when you don't dispose the frame after Add: |
No, that's not why. Look at the stack, the exception occurs when Dispose() is called multiple times (which should be fine to do). The problem is with Dispose() which just calls Finish(), and that looks like this:
Notice that _stream is disposed, but never set to null. This means repeated calls to Dispose() throws ObjectDisposedException. |
System.ObjectDisposedException: Cannot access a closed Stream.
at System.IO.Strategies.BufferedFileStreamStrategy.WriteByteSlow(Byte value)
at System.IO.Strategies.BufferedFileStreamStrategy.WriteByte(Byte value)
at System.IO.FileStream.WriteByte(Byte value)
at AnimatedGif.AnimatedGifCreator.Finish()
at AnimatedGif.AnimatedGifCreator.Dispose()
This occurs if the caller did this:
Personally I think there should be a public API for letting the user commit and close the file ahead of dispose, but a simple fix would be to set _stream to null after disposing.
The text was updated successfully, but these errors were encountered: