[BUG] BitmapLoader throws InvalidOperationException when loading from network stream
n-ski opened this issue · 2 comments
n-ski commented
This is the duplicate of #86, but since that one is closed, I'm creating a new issue.
Describe the bug
When loading a bitmap from a network stream using BitmapLoader.Current.Load()
, InvalidOperationException
is thrown.
<System.InvalidOperationException: This Freezable cannot be frozen.
at System.Windows.Freezable.Freeze()
at Splat.PlatformBitmapLoader.WithInit(BitmapImage source, Action`1 block) in /_/src/Splat.Drawing/Platforms/net5/Bitmaps/PlatformBitmapLoader.cs:line 89
at Splat.PlatformBitmapLoader.<>c__DisplayClass0_0.<Load>b__0() in /_/src/Splat.Drawing/Platforms/net5/Bitmaps/PlatformBitmapLoader.cs:line 26
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__277_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
at NUnit.Framework.Internal.ExceptionHelper.RecordException(Delegate parameterlessDelegate, String parameterName)>
Steps To Reproduce
Project must target Windows platform (tested with WPF).
using HttpClient client = new();
using Stream stream = await client.GetStreamAsync("https://via.placeholder.com/150");
// Next line throws InvalidOperationException.
IBitmap bitmap = await BitmapLoader.Current.Load(stream, default, default);
Expected behavior
Bitmap should be loaded without throwing.
Environment:
- OS: Windows 10 1809 x64
- .NET SDK: 5.0.206
- .NET Windows Desktop runtime: 5.0.9
glennawatson commented
Closed by #793
github-actions commented
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.