Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xamarin.ios 升级到Azure Mobile Services 1.3.1后出错_Xamarin.ios_Azure Mobile Services - Fatal编程技术网

Xamarin.ios 升级到Azure Mobile Services 1.3.1后出错

Xamarin.ios 升级到Azure Mobile Services 1.3.1后出错,xamarin.ios,azure-mobile-services,Xamarin.ios,Azure Mobile Services,我有一个Xamarin.iOS项目,最近升级了该项目,加上我的PCL项目,使其具有Windows Azure移动服务SDK 1.3.1 但是,当它尝试创建一个新的MobileServiceClient时,我现在遇到了一个错误 {System.NullReferenceException: Object reference not set to an instance an object at Microsoft.WindowsAzure.MobileServices.MobileServ

我有一个Xamarin.iOS项目,最近升级了该项目,加上我的PCL项目,使其具有Windows Azure移动服务SDK 1.3.1

但是,当它尝试创建一个新的MobileServiceClient时,我现在遇到了一个错误

{System.NullReferenceException: Object reference not set to an instance     an object
at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.GetUserAgentHeader () [0x0002e] in d:\jw\ZumoSDKBuild_Dev\source\sdk\Managed\src\Microsoft.WindowsAzure.MobileServices\Http\MobileServiceHttpClient.cs:683 
at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient..ctor (IEnumerable`1 handlers, System.Uri applicationUri, System.String installationId, System.String applicationKey) [0x0004e] in d:\jw\ZumoSDKBuild_Dev\source\sdk\Managed\src\Microsoft.WindowsAzure.MobileServices\Http\MobileServiceHttpClient.cs:138 
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor (System.Uri applicationUri, System.String applicationKey, System.Net.Http.HttpMessageHandler[] handlers) [0x00040] in d:\jw\ZumoSDKBuild_Dev\source\sdk\Managed\src\Microsoft.WindowsAzure.MobileServices\MobileServiceClient.cs:199 
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor (System.Uri applicationUri, System.String applicationKey) [0x00000] in d:\jw\ZumoSDKBuild_Dev\source\sdk\Managed\src\Microsoft.WindowsAzure.MobileServices\MobileServiceClient.cs:150 
at Microsoft.WindowsAzure.MobileServices.MobileServiceClient..ctor (System.String applicationUrl, System.String applicationKey) [0x00000] in d:\jw\ZumoSDKBuild_Dev\source\sdk\Managed\src\Microsoft.WindowsAzure.MobileServices\MobileServiceClient.cs:135 
at MyApp.App..ctor () [0x00009] in c:\Users\adam\Documents\Visual Studio 2013\Projects\MyApp\App.cs:30 }
查看MobileServiceClient的源代码,这里是它失败的功能

            private string GetUserAgentHeader() 
678         { 
679             AssemblyFileVersionAttribute fileVersionAttribute = typeof(MobileServiceClient).GetTypeInfo().Assembly 
680                                                                         .GetCustomAttributes(typeof(AssemblyFileVersionAttribute)) 
681                                                                         .Cast<AssemblyFileVersionAttribute>() 
682                                                                         .FirstOrDefault(); 
683             string fileVersion = fileVersionAttribute.Version; 
684             string sdkVersion = string.Join(".", fileVersion.Split('.').Take(2)); // Get just the major and minor versions 
685 

686             IPlatformInformation platformInformation = Platform.Instance.PlatformInformation; 
687             return string.Format( 
688                 CultureInfo.InvariantCulture, 
689                 "ZUMO/{0} (lang={1}; os={2}; os_version={3}; arch={4}; version={5})", 
690                 sdkVersion, 
691                 "Managed", 
692                 platformInformation.OperatingSystemName, 
693                 platformInformation.OperatingSystemVersion, 
694                 platformInformation.OperatingSystemArchitecture, 
695                 fileVersion); 
696         } 
私有字符串GetUserAgentHeader()
678         { 
679 AssemblyFileVersionAttribute fileVersionAttribute=typeof(MobileServiceClient).GetTypeInfo().Assembly
680.GetCustomAttributes(typeof(AssemblyFileVersionAttribute))
681.Cast()
682.FirstOrDefault();
683字符串fileVersion=fileVersionAttribute.Version;
684 string sdkVersion=string.Join(“.”,fileVersion.Split(“.”)。Take(2));//只获取主要版本和次要版本
685
686 IPlatformInformation platformation=Platform.Instance.platformation;
687返回字符串。格式(
688 CultureInfo.InvariantCulture,
689“ZUMO/{0}(lang={1};os={2};os_version={3};arch={4};version={5})”,
690 sdkVersion,
691“管理”,
692平台信息。操作系统名称,
693平台信息。操作系统版本,
694平台信息。操作系统架构,
695个文件版本);
696         } 
我不知道具体是什么导致了这个错误。谢谢你的帮助

更新

如果我在尝试初始化MobileServiceClient之前在我的应用程序中运行以下代码

AssemblyFileVersionAttribute fileVersionAttribute = typeof(MobileServiceClient).GetTypeInfo().Assembly 
                                                                        .GetCustomAttributes(typeof(AssemblyFileVersionAttribute)) 
                                                                        .Cast<AssemblyFileVersionAttribute>() 
                                                                         .FirstOrDefault(); 
             string fileVersion = fileVersionAttribute.Version; 
AssemblyFileVersionAttribute fileVersionAttribute=typeof(MobileServiceClient).GetTypeInfo().Assembly
.GetCustomAttributes(类型(AssemblyFileVersionAttribute))
.Cast()
.FirstOrDefault();
字符串fileVersion=fileVersionAttribute.Version;
与“不要链接”一起,它可以完美地工作。若我使用linksdk或linkall运行它,那个么assembly就等于null

我还不确定从这里到哪里去。

我需要补充

CurrentPlatform.Init(); 
在AppDelegate的FinishedLaunching中

第二,在iOS项目中,我需要去

Properties > iOS Build > Linker Behavior and set it to "Don't link"
我仍然不认为这是答案,只是目前的一个拙劣的工作。

< P>我需要添加< /P>
CurrentPlatform.Init(); 
在AppDelegate的FinishedLaunching中

第二,在iOS项目中,我需要去

Properties > iOS Build > Linker Behavior and set it to "Don't link"
我仍然不认为这是答案,只是目前的一个拙劣的工作。

< P>我需要添加< /P>
CurrentPlatform.Init(); 
在AppDelegate的FinishedLaunching中

第二,在iOS项目中,我需要去

Properties > iOS Build > Linker Behavior and set it to "Don't link"
我仍然不认为这是答案,只是目前的一个拙劣的工作。

< P>我需要添加< /P>
CurrentPlatform.Init(); 
在AppDelegate的FinishedLaunching中

第二,在iOS项目中,我需要去

Properties > iOS Build > Linker Behavior and set it to "Don't link"

<>我仍然不认为这是答案,它只是一个很差的工作目前。

< p>我终于发现了一种防止Azure移动服务库链接的方法,而不禁用其他所有的链接。p> 你可以加上

--linkskip=Microsoft.WindowsAzure.Mobile --linkskip=Microsoft.WindowsAzure.Mobile.Ext
在iOS项目的“项目设置”下的“iOS生成选项”中添加其他mtouch参数


这将跳过azure程序集的链接器,但不会跳过其余程序集的链接器。有关链接器的更多信息,请访问

我终于找到了一种方法,可以在不禁用其他链接的情况下阻止Azure移动服务库的链接

你可以加上

--linkskip=Microsoft.WindowsAzure.Mobile --linkskip=Microsoft.WindowsAzure.Mobile.Ext
在iOS项目的“项目设置”下的“iOS生成选项”中添加其他mtouch参数


这将跳过azure程序集的链接器,但不会跳过其余程序集的链接器。有关链接器的更多信息,请访问

我终于找到了一种方法,可以在不禁用其他链接的情况下阻止Azure移动服务库的链接

你可以加上

--linkskip=Microsoft.WindowsAzure.Mobile --linkskip=Microsoft.WindowsAzure.Mobile.Ext
在iOS项目的“项目设置”下的“iOS生成选项”中添加其他mtouch参数


这将跳过azure程序集的链接器,但不会跳过其余程序集的链接器。有关链接器的更多信息,请访问

我终于找到了一种方法,可以在不禁用其他链接的情况下阻止Azure移动服务库的链接

你可以加上

--linkskip=Microsoft.WindowsAzure.Mobile --linkskip=Microsoft.WindowsAzure.Mobile.Ext
在iOS项目的“项目设置”下的“iOS生成选项”中添加其他mtouch参数


这将跳过azure程序集的链接器,但不会跳过其余程序集的链接器。有关链接器的更多信息,请访问

链接的目的是通过排除未使用的名称空间、类和成员来减少应用程序的总体大小。链接大多数应用程序需要手动迭代过程,包括:

  • 为您关心的任何构建配置启用完全链接
  • 清理并构建应用程序
  • 运行应用程序,观察由于缺少类型和方法(包括构造函数)而导致的运行时异常
  • 将规则添加到mtouch命令参数或链接描述XML文件中,以跳过对引发异常的命名空间、类型和类的链接
  • 为了链接使用Azure移动服务客户端PCL的应用程序,您需要遵循我刚才提到的相同迭代过程

    我更喜欢链接保存的基于XML的配置文件策略:

    XML文件通常称为链接定义文件。它允许您以声明方式控制链接器,而无需在代码中的任何地方添加
    [Preserve]
    属性;对于第三方图书馆,