Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Please note this is an issue introduced for Ver 4.2.2!!!
In ver 4.2.1 - the code works fine.
I'm getting the following error in ver 4.2.2:
System.ObjectDisposedException: The object was used after being disposed.
when calling fs.Length in the code below.
using (Android.Graphics.Bitmap bitmap = Android.Graphics.BitmapFactory.DecodeByteArray(jpegData, 0, jpegData.Length))
using (System.IO.FileStream fs = new System.IO.FileStream(Program.AppImageFileSpec, System.IO.FileMode.Create))
bitmap.Compress(Android.Graphics.Bitmap.CompressFormat.Jpeg, 75, fs);
var sizeInfo = fs.Length;// System.ObjectDisposedException: The object was used after being disposed.
The same also occurs in this code dealing with the MemoryStream:
using (MemoryStream ms = new MemoryStream())
bitmap.Compress(Bitmap.CompressFormat.Jpeg, 75, ms);
TaskAssignment.TaskImage.ImageAsImage = ms.ToArray();
sizeInfo = DBT.helpers.ceHelper.GetSpaceDescription((ulong)ms.Length);
Looking in the 4.2.2 notes I saw this:
Reduce lifetime of wrapped Streams in InputStreamAdapter, InputStreamInvoker, OutputStreamAdapter, OutputStreamInvoker. Disposing of the wrapper instance will now dispose the wrapped instance.
Is there any chance this is related?
Is there an interim workaround where I can get the Length?
This should be fixed by commit d5363f65, and will be fixed in the 4.2.3 release.
I'm sorry for the inconvenience.