繁体   English   中英

为什么使用Microsoft Azure移动服务时Xamarin Forms iOS应用程序崩溃

[英]Why is my Xamarin Forms iOS app crashing when using Microsoft Azure Mobile Services

我的Xamarin Forms应用程序有一个奇怪的问题,我似乎无法解决,我似乎正与它绕圈子。 它似乎与我的iOS项目特别相关,并且围绕程序集引用Microsoft.WindowsAzure.Mobile 当我在iPhone模拟器上运行我的应用程序,然后尝试查看从Azure获取数据的应用程序的任何部分时,将触发以下消息。

System.InvalidOperationException:找不到用于当前平台的Microsoft Azure移动服务程序集。 确保当前项目同时引用Microsoft.WindowsAzure.Mobile和以下特定于平台的程序集:Microsoft.WindowsAzure.Mobile.Ext。

我发现这很奇怪,因为我安装了我认为是所有正确的参考文献:

整个解决方案使用Xamarin.Forms v2.3.4.247

MyApp(便携式)

  • WindowsAzure.MobileServices 1.3.2
  • WindowsAzure.MobileService.SQLiteStore 1.0.1

MyApp.iOS

  • Microsoft.Azure.Mobile.Client 4.0.1
  • Microsoft.Azure.Mobile.Client.SQLiteStore 4.0.1

我以为iOS项目的app.config损坏了,或者在我安装了这些nuget软件包时可能丢失了一些信息,所以我快速浏览了一下,看上去都应该如此。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.5.0.0" newVersion="1.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="PInvoke.BCrypt" publicKeyToken="9e300f9f87f04a7a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-0.5.0.0" newVersion="0.5.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Validation" publicKeyToken="2fc06f0d701809a7" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.4.0.0" newVersion="2.4.0.0" />
      </dependentAssembly>
     <dependentAssembly>
        <assemblyIdentity name="Microsoft.WindowsAzure.Mobile" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.29.0" newVersion="4.2.29.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

如果需要,我可以提供更多代码,但我想将问题本地化到我所看到的以及报告问题的位置。 有谁知道是什么原因引起的,或者我需要采取什么措施来解决它? 可能是引起问题的版本,我应该考虑回滚吗?

AFAIK, WindowsAzure.MobileServices现在已弃用,并且可以与移动服务( {your-app-name} .azure-mobile.net之类的域 )一起使用。 虽然Microsoft.Azure.Mobile.Client用于与Mobile Apps(App Service, {your-app-name} .azurewebsites.net之类的域 )一起使用。

有谁知道是什么原因引起的,或者我需要采取什么措施来解决它? 可能是引起问题的版本,我应该考虑回滚吗?

我注意到,您的iOS项目的app.config有dependentAssembly约Microsoft.WindowsAzure.Mobile与NEWVERSION 1.3.0.0。

据我了解,您已经安装了WindowsAzure.MobileServices和Microsoft.Azure.Mobile.Client软件包,建议您使用相同的软件包来缩小此问题的范围。 另外,在使用MobileServiceClient之前,您需要通过以下代码初始化azure mobile:

Microsoft.WindowsAzure.MobileServices.CurrentPlatform.Init();

此外,我检查了已安装Microsoft.Azure.Mobile.Client 3.1.0的 xamarin.forms应用程序,它可以按预期运行。 这是有关azure-mobile-apps-quickstarts的git示例,您可以参考它。 此外,这是一个类似的git问题,您可以在此处参考。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM