3

我有一个应用程序现在需要部署到应用程序商店,因为由于 Gatekeeper,它正在慢慢变得不可避免。

唯一的问题是 Web 请求似乎失败了,因为它们甚至没有被触发。

以下代码片段是从 Xamarin Bugzilla 文章中提取的,并且在为 Release 和 Debug 构建时成功;

            try
            {
                WebClient test = new WebClient();
                Console.WriteLine("Testing SSL GET...");
                string testresponse = test.DownloadString(checkFileUrl);
                Console.WriteLine("testresponse = " + testresponse);
            } catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.InnerException.Message);
            }

但是,当我使用沙盒和网络 IO 授权切换到 AppStore 构建时,请求永远不会被发送出去,正如Charles在非 SSL 解密模式下所验证的那样。以下内容从控制台中吐出;

Testing SSL GET...
Error getting response stream (Write: The authentication or decryption has failed.): SendFailure
The authentication or decryption has failed.

这似乎是问题所在,因为我们使用对 IIS 服务进行的 SOAP 调用来执行操作,首先是登录。对于调试和发布,登录工作正常,因为调用已完成。再一次,AppStore 构建甚至没有尝试联系。

证书是有效的,并且 CA 安装在我的钥匙串中。

在此之前,我在代码中(在调试中)遇到了一些异常,例如;

System.Exception..ctor (message="invalid encoding specification.") in /private/tmp/source/bockbuild-mono-3.2.6/profiles/mono-mac-xamarin/build-root/mono-3.2.6/mcs/class/corlib/System/Exception.cs:81

System.Exception..ctor (message="Store Root doesn't exists.") in /private/tmp/source/bockbuild-mono-3.2.6/profiles/mono-mac-xamarin/build-root/mono-3.2.6/mcs/class/corlib/System/Exception.cs:81

System.Exception..ctor (message="Store CA doesn't exists.") in /private/tmp/source/bockbuild-mono-3.2.6/profiles/mono-mac-xamarin/build-root/mono-3.2.6/mcs/class/corlib/System/Exception.cs:81

这仍然让我相信这是一个证书问题。测试 URL 是 S3 链接,登录服务器是具有有效证书的 EC2 实例。

干杯。

4

1 回答 1

1

检查您的应用程序是如何打包的。

默认情况下,在构建项目时(在 Xamarin Studio 或 Visual Studio 中),它将调用一个名为的工具mtouch,其中包括托管代码的链接器。此工具用于从应用程序未使用的类库中删除功能。

或者mtouch希望你相信。

链接器行为的默认选项是 to Link all assembiles。这将用于尝试通过修改用户代码mtouch使应用程序尽可能小。这可以并且将会破坏以无法检测的方式使用功能的代码(例如 Web 服务、反射或序列化)。mtouch

我使用的解决方法是禁用链接。通过将链接器行为更改为Don't Link,这将确保没有修改任何程序集。

您可以通过右键单击相关项目并选择来找到执行此操作的菜单Options

Xamarin Studio - 项目选项窗口

特定项目中的链接器行为

尝试将链接器行为更改为Don't Link(如上所示)并重建。

更多信息

Xamarin 指南 - 与 iOS 的链接器

于 2014-03-30T04:22:21.647 回答