哈玛林。Android(mono), TypeLoadException : " Could not load type 'CameraInfo' "



我使用以下代码片段使用从 http://components.xamarin.com/gettingstarted/zxing.net.mobile 下载的Zxing条形码库读取条形码。应用程序最小版本被选为2.3,目标版本被选为自动。我正在 nexus 4 (Android 4.4.2) 上运行该应用程序

    BarcodeButton.Click += async delegate 
    {
        var scanner = new ZXing.Mobile.MobileBarcodeScanner(this);
        var result = await scanner.Scan();
        if (result != null)                 
            Toast.MakeText(this,"DONE",ToastLength.Short).Show();
    };

当我运行应用程序时,按下条形码按钮后会获得此错误日志。错误是什么?我该如何解决?:

                              ...
[Mono] Assembly Ref addref ZXing.Net.Mobile[0x784bb038] -> mscorlib[0x777e2a10]: 9
[Mono] Assembly Ref addref TeleLib[0x784b8c58] -> zxing.monoandroid[0x784ba440]: 2
[Mono] The request to load the assembly mscorlib v2.0.5.0 was remapped to v2.0.0.0
[Mono] Unloading image mscorlib.dll [0x78801068].
[Mono] Assembly Ref addref zxing.monoandroid[0x784ba440] -> mscorlib[0x777e2a10]: 10
[Mono] Assembly Ref addref ZXing.Net.Mobile[0x784bb038] -> Mono.Android[0x784bbb98]: 4
[Mono] Assembly Ref addref ZXing.Net.Mobile[0x784bb038] -> zxing.monoandroid[0x784ba440]: 3
[Mono] Assembly Ref addref ZXing.Net.Mobile[0x784bb038] -> Xamarin.Android.Support.v4[0x784b9848]: 2
[Mono] Assembly Ref addref zxing.monoandroid[0x784ba440] -> Mono.Android[0x784bbb98]: 5
[] TypeRef ResolutionScope not yet handled (14) for .CameraInfo in image /data/data/TeleLib.TeleLib/files/.__override__/ZXing.Net.Mobile.dll
[Mono] The class CameraInfo could not be loaded, used in 
[MonoDroid] UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'CameraInfo'.
[MonoDroid] at Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder_ (intptr,intptr,intptr) <0x0005f>
[MonoDroid] at (wrapper dynamic-method) object.c17a61df-f7d9-45dc-ba1c-dac5c5d9eb39 (intptr,intptr,intptr) <0x00043>
[mono] 
[mono] Unhandled Exception:
[mono] System.TypeLoadException: Could not load type 'CameraInfo'.
[mono]   at Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder_ (IntPtr jnienv, IntPtr native__this, IntPtr native_holder) [0x00000] in <filename unknown>:0 
[mono]   at (wrapper dynamic-method) object:c17a61df-f7d9-45dc-ba1c-dac5c5d9eb39 (intptr,intptr,intptr)
[mono-rt] [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: Could not load type 'CameraInfo'.
[mono-rt]   at Android.Views.ISurfaceHolderCallbackInvoker.n_SurfaceCreated_Landroid_view_SurfaceHolder_ (IntPtr jnienv, IntPtr native__this, IntPtr native_holder) [0x00000] in <filename unknown>:0 
[mono-rt]   at (wrapper dynamic-method) object:c17a61df-f7d9-45dc-ba1c-dac5c5d9eb39 (intptr,intptr,intptr)

我遇到了同样的问题,并发现 ZXing.NET 组件需要Android版本2.3。将项目更改为目标 2.3 或更高版本,此错误将消失。

相关内容

最新更新