引用ReactiveUI 7.4时iOS启动错误

Max*_*mus 6 xamarin.ios reactiveui xamarin xamarin.forms

我有一个带有.Net Standard 1.4核心库的Xamarin Forms项目,它包含所有代码.我在核心和iOS项目中都引用了ReactiveUI 7.4.但是当我在iOS模拟器上编译并运行时,我在应用程序启动时收到以下错误:

2017-08-24 13:39:39.040 TestProject.iOS[25074:307385] Could not register the assembly 'ReactiveUI': System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
  at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
  at System.Reflection.Assembly.GetTypes () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.12.0.20/src/mono/mcs/class/corlib/System.Reflection/Assembly.cs:410 
  at Registrar.DynamicRegistrar.CollectTypes (System.Reflection.Assembly assembly) [0x00000] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/ObjCRuntime/DynamicRegistrar.cs:237 
  at Registrar.Registrar.RegisterAssembly (System.Reflection.Assembly assembly) [0x00056] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/ObjCRuntime/Registrar.cs:1978 


Loaded assembly: /Library/Frameworks/Xamarin.Interactive.framework/Versions/Current/Agents/iOS/Xamarin.Interactive.iOS.dll [External]
Loaded assembly: /Library/Frameworks/Xamarin.Interactive.framework/Versions/Current/Agents/iOS/Xamarin.Interactive.dll [External]
Unhandled Exception:

System.BadImageFormatException: <Timeout exceeded getting exception details>
Run Code Online (Sandbox Code Playgroud)

Unhandled Exception:
System.BadImageFormatException: Could not resolve field token 0x040000fd
File name: 'ReactiveUI'
  at TestProject.iOS.AppDelegate..ctor () [0x00008] in C:\TestProject\TestProject.iOS\AppDelegate.cs:24 
  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 /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/4991/80b8487d/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
  at TestProject.iOS.Application.Main (System.String[] args) [0x00001] in C:\TestProject\TestProject.iOS\Main.cs:17 
2017-08-24 13:39:46.074 TestProject.iOS[25074:307385] Unhandled managed exception:
Run Code Online (Sandbox Code Playgroud)

任何人都收到此错误?

更新:

以下是在iOS上重现的错误的链接:

https://github.com/assassin316/ReactiveUIError

Sha*_*lle 4

所以我认为发生了一些事情并且该项目设置不太正确

1)您需要将reactiveui nuget安装到所有平台项目中

现在你只将reactiveui-core安装到iOS项目中,你还需要安装ReactiveUI

https://github.com/assassin316/ReactiveUIError/blob/master/ReactiveUIErrorTest/ReactiveUIErrorTest.iOS/packages.config

2)iOS项目本身根本没有引用System.Reactive库 https://github.com/assassin316/ReactiveUIError/blob/master/ReactiveUIErrorTest/ReactiveUIErrorTest.iOS/ReactiveUIErrorTest.iOS.csproj

因此它们只存在于packages.config文件中从packages.config文件中删除Rx-*条目并使用包管理器控制台手动安装它们

Install-Package Rx-Main -Version 2.2.5
Install-Package Rx-PlatformServices -Version 2.2.5
Install-Package Rx-Core -Version 2.2.5
Run Code Online (Sandbox Code Playgroud)

或者只是将其添加到 iOS 项目的 csproj 文件中

<Reference Include="System.Reactive.Core, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\..\packages\Rx-Core.2.2.5\lib\portable-windows8+net45+wp8\System.Reactive.Core.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Interfaces, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\..\packages\Rx-Interfaces.2.2.5\lib\portable-windows8+net45+wp8\System.Reactive.Interfaces.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Linq, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\..\packages\Rx-Linq.2.2.5\lib\portable-windows8+net45+wp8\System.Reactive.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.PlatformServices, Version=2.2.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
  <HintPath>..\..\packages\Rx-PlatformServices.2.2.5\lib\portable-windows8+net45+wp8\System.Reactive.PlatformServices.dll</HintPath>
</Reference>
Run Code Online (Sandbox Code Playgroud)

或者将 iOS 项目转换为使用 PackageReferences

3)Reactiveui-xamforms也需要安装到平台项目中

此时我可以运行你的项目了

您对该问题的最佳提示位于您发布的例外之上

2017-09-02 12:57:43.983 Sekuence.iOS [86898:37039424]找不到程序集ReactiveUI引用的System.Reactive.Core,版本= 7.4.0.0,文化=中性,PublicKeyToken = null。

2017-09-02 12:57:43.985 Sekuence.iOS [86898:37039424]找不到程序集ReactiveUI引用的System.Reactive.Interfaces,版本= 7.4.0.0,文化=中性,PublicKeyToken = null。

2017-09-02 12:57:43.986 Sekuence.iOS [86898:37039424]找不到程序集ReactiveUI引用的System.Reactive.Linq,版本= 7.4.0.0,文化=中性,PublicKeyToken = null。

2017-09-02 12:57:43.986 Sekuence.iOS[86898:37039424] 找不到程序集 ReactiveUI 引用的 System.Reactive.PlatformServices,Version=7.4.0.0,Culture=neutral,PublicKeyToken=null。

2017-09-02 12:57:44.029 Sekuence.iOS[86898:37039424] 找不到程序集 ReactiveUIErrorTest.Core 引用的 System.Reactive.Core,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null。

2017-09-02 12:57:44.030 Sekuence.iOS[86898:37039424] 找不到程序集 ReactiveUIErrorTest.Core 引用的 ReactiveUI.XamForms,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null。

所以基本上它是说找不到任何这些 DLL。我查看了 iOS 项目的 bin 文件夹,果然没有这些文件。所以我只是重新安装了所有这些软件包,然后一切正常