Xamarin.forms: [Android、PCL] - ImageLoaderSourceHandler:无法检索图像或图像数据无效

创建于 2018-02-13  ·  3评论  ·  资料来源: xamarin/Xamarin.Forms

描述

  • 在 Android 上,使用最新的 Forms 和一个 PCL 项目......一个带有硬编码 ImageSource may超时的 XAML ImageCell 并返回一个错误。

  • 与 Shared 或 .NET Standard 解决方案一起使用时似乎可以正常工作

  • 仅在模拟中测试

<ImageCell
    ImageSource="https://www.xamstatic.com/dist/images/pages/platform/visual-studio-icon-uHIZMvQl.png"
    Text="{Binding Name}"
    Detail="{Binding Job}">
</ImageCell>
Image Loading: Error getting stream for https://www.xamstatic.com/dist/images/pages/platform/visual-studio-icon-uHIZMvQl.png: System.Threading.Tasks.TaskCanceledException: A task was canceled.
...
[0:] ImageLoaderSourceHandler: Could not retrieve image or image data was invalid: Uri: https://www.xamstatic.com/dist/images/pages/platform/visual-studio-icon-uHIZMvQl.png

重现步骤

  1. 使用下面的repo ,加载 PCL 示例
  2. 应该看到带有 Visual Studio 图标的 ImageCell 列表
  3. 检查输出是否有错误和超时
  4. 错误没有发生? 卸载应用程序并重试。

预期行为

加载所有图像,就像在共享和 .NET Standard 解决方案中一样


实际行为

链接到完整的输出日志

[0:] Image Loading: Error getting stream for https://www.xamstatic.com/dist/images/pages/platform/visual-studio-icon-uHIZMvQl.png: System.Threading.Tasks.TaskCanceledException: A task was canceled.
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00026] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Net.Http.HttpClientHandler+<SendAsync>d__63.MoveNext () [0x00528] in <35658e59c86d40bdbb2ef0bb34b4f0c7>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Net.Http.HttpClient+<SendAsyncWorker>d__49.MoveNext () [0x000ca] in <35658e59c86d40bdbb2ef0bb34b4f0c7>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at Xamarin.Forms.Forms+AndroidPlatformServices+<GetStreamAsync>d__16.MoveNext () [0x0003e] in D:\agent\_work\2\s\Xamarin.Forms.Platform.Android\Forms.cs:448 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0001a] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 
  at Xamarin.Forms.UriImageSource+<GetStreamAsyncUnchecked>d__23.MoveNext () [0x00224] in D:\agent\_work\2\s\Xamarin.Forms.Core\UriImageSource.cs:174 
[0:] ImageLoaderSourceHandler: Could not retrieve image or image data was invalid: Uri: https://www.xamstatic.com/dist/images/pages/platform/visual-studio-icon-uHIZMvQl.png

基本信息

  • 有问题的版本:Xamarin.Forms:2.5.0.91635
  • 平台目标框架:

复制链接

https://github.com/mattregul/XF_ImageCellIssue

regression Android bug

最有用的评论

哎呀! 找不到那个页面。

这个网址效果更好(在打字时): https :

所有3条评论

我遇到了同样的问题,我发现这是因为我像您一样从 SSL URL 加载了图像。 这是该问题的解决方案https://doumer.me/2018/03/29/resolve-image-loading-error-in-xamarin-forms/
我通过更改 SSL 和 TLS 设置解决了它。

哎呀! 找不到那个页面。

这个网址效果更好(在打字时): https :

原始 repro 中的图像 url 在这一点上似乎完全损坏了我无法在浏览器或 netstandard 或 PCL 中加载该图像

话虽如此,我刚刚找到了一些其他网址,但未能在 2.5 上加载图像
然后我将 PCL 示例更新为 3.1 并将所有图像加载到那里

如果我的评估似乎有误,请告诉我并附上 3.1 副本

此页面是否有帮助?
0 / 5 - 0 等级