c# - 请在特定于平台的项目中调用 CachedImageRenderer.Init 方法以使用 FFImageLoading?

标签 c# xamarin.ios

尝试在 iO 上使用 Xamarin FFImageLoading 插件时出现此异常:

System.Exception: Please call CachedImageRenderer.Init method in a platform specific project to use FFImageLoading!
  at FFImageLoading.Forms.CachedImage.OnSourcePropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00007] in C:\projects\ffimageloading\source\FFImageLoading.Forms\CachedImage.cs:133 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:625 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\a\1\s\Xam
arin.Forms.Core\BindableObject.cs:417 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0003d] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:573 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:99 
  at FFImageLoading.Forms.CachedImage.set_Source (Xamarin.Forms.ImageSource value) [0x00000] in C:\projects\ffimageloading\source\FFImageLoading.Forms\CachedImage.cs:173 
  at Demo.MainViewModel..ctor () [0x0001f] in <4cd5393447f94973bb9eef7c0de8880d>:0 
  at FullCameraApp.CameraPage.getLayoutImage (System.Int32 index) [0x00001] in <4cd5393447f94973bb9eef7c0de8880d>:0 
  at FullCameraApp.CameraPage..ctor (ScoreScan.webServices.WebServices webServices, System.Collections.Generic.List`1[T] imageBytesList) [0x0060b] in <4cd5393447f94973bb9eef7c0de8880d>:0 
  at ScoreScan.App..ctor () [0x0
0025] in <4cd5393447f94973bb9eef7c0de8880d>:0 
  at ScoreScan.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x0000d] in <4cd5393447f94973bb9eef7c0de8880d>:0 
  at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.14.0.14/src/Xamarin.iOS/UIKit/UIApplication.cs:63 
  at ScoreScan.iOS.Application.Main (System.String[] args) [0x00001] in <4cd5393447f94973bb9eef7c0de8880d>:0 
2018-10-08 19:47:10.229 ScoreScan.iOS[324:13181] Unhandled managed exception:
Please call CachedImageRenderer.Init method in a platform specific project to use FFImageLoading! (System.Exception)
  at FFImageLoading.Forms.CachedImage.OnSourcePropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x00007] in C:\projects\ffimageloading\source\FFImageLoading.Forms\CachedImage.cs:133 
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.Internals.SetValueFlags attributes, System.Boolean silent) [0x00120] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:625 
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.Internals.SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in D:\a
\1\s\Xamarin.Forms.Core\BindableObject.cs:417 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0003d] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:573 
  at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:99 
  at FFImageLoading.Forms.CachedImage.set_Source (Xamarin.Forms.ImageSource value) [0x00000] in C:\projects\ffimageloading\source\FFImageLoading.Forms\CachedImage.cs:173 
  at Demo.MainViewModel..ctor () [0x0001f] in <4cd5393447f94973bb9eef7c0de8880d>:0 
  at FullCameraApp.CameraPage.getLayoutImage (System.Int32 index) [0x00001] in <4cd5393447f94973bb9eef7c0de8880d>:0 
  at FullCameraApp.CameraPage..ctor (ScoreScan.webServices.WebServices webServices, System.Collections.Generic.List`1[T] imageBytesList) [0x0060b] in <4cd5393447f94973bb9eef7c0de8880d>:0 
  at ScoreScan.App..ctor
ktrace:

如何解决这个异常?

最佳答案

在 global::Xamarin.Forms.Forms.Init() 之后调用 CachedImageRenderer.Init;在 iOS 项目的 AppDelegate.cs 文件中的 FinishedLaunching 方法中。

它清楚地提到您需要在其中调用 Init 方法。详情将在FFImageLoading插件的github仓库中给出

下面提到了link

关于c# - 请在特定于平台的项目中调用 CachedImageRenderer.Init 方法以使用 FFImageLoading?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52711881/

相关文章:

c# - 使用 Autofac 和 Moq 进行集成测试

C# - MySQL 与 Microsoft SQL Server

ios - 如何使用 DeviceCheck.DCDevice Xamarin Forms C# 生成 token 代码 iOS DeviceId

ios - Xamarin iOS - 以编程方式加载 Storyboard引用

c# - 有什么办法可以使它成为更快的算法吗?

c# - 请确认 .NET 4.0 中路径长度相关行为的变化

c# - .NET2 DNS 拒绝超过 126 个字符的主机名,如 "too long"

c# - 在 C# 中为 Xamarin 禁用泛型

android - MonoTouch/MonoDroid 服务层不兼容?

web-services - MonoTouch、Sharepoint Web 服务和 xs :any