REST API可在邮递员和浏览器中使用,但在应用于项目时将无法使用

时间:2018-07-09 13:24:13

标签: rest xamarin.forms

我有一个奇怪的问题。

我正在开发xamarin表单应用程序。我的REST API在邮递员和浏览器中运行,但是当我将这些REST API应用到项目中时,它们将无法正常工作。在项目中已经运行了许多REST API,但是不知道为什么它现在不起作用。我正在使用以下代码:

        HttpClient client = new HttpClient();
        Debug.WriteLine("Enter here");
        var siteIdResponse = await client.GetAsync(My REST API);
        Debug.WriteLine("siteIdResponse:>" + siteIdResponse);
        if (siteIdResponse.IsSuccessStatusCode)
        {
               //codes
        }

输出:

[0:] Enter here
Thread started:  #7
07-09 18:48:10.231 D/Mono    (21753): Image addref Mono.Security[0xb8ebcc80] -> Mono.Security.dll[0xb8e9be58]: 2
07-09 18:48:10.231 D/Mono    (21753): Prepared to set up assembly 'Mono.Security' (Mono.Security.dll)
07-09 18:48:10.231 D/Mono    (21753): Assembly Mono.Security[0xb8ebcc80] added to domain RootDomain, ref_count=1
07-09 18:48:10.232 D/Mono    (21753): AOT: image 'Mono.Security.dll.so' not found: dlopen failed: library "/mnt/asec/com.pagematics.Business_App-1/lib/arm/libaot-Mono.Security.dll.so" not found
07-09 18:48:10.233 D/Mono    (21753): AOT: image '/usr/local/lib/mono/aot-cache/arm/Mono.Security.dll.so' not found: dlopen failed: library "/mnt/asec/com.pagematics.Business_App-1/lib/arm/libaot-Mono.Security.dll.so" not found
07-09 18:48:10.233 D/Mono    (21753): Config attempting to parse: 'Mono.Security.dll.config'.
07-09 18:48:10.234 D/Mono    (21753): Config attempting to parse: '/usr/local/etc/mono/assemblies/Mono.Security/Mono.Security.config'.
07-09 18:48:10.234 D/Mono    (21753): Assembly Ref addref System[0xb851f108] -> Mono.Security[0xb8ebcc80]: 2
07-09 18:48:10.234 D/Mono    (21753): Assembly Ref addref Mono.Security[0xb8ebcc80] -> mscorlib[0xb82cfaf0]: 58
Loaded assembly: Mono.Security.dll [External]
07-09 18:48:10.297 D/Mono    (21753): Assembly Ref addref System.Net.Http[0xb8e80b50] -> System.Core[0xb844e178]: 7
07-09 18:48:10.388 D/Mono    (21753): Assembly Ref addref Mono.Android[0xb834d360] -> System[0xb851f108]: 15
07-09 18:48:10.790 I/Choreographer(21753): Skipped 100 frames!  The application may be doing too much work on its main thread.
Thread started: <Thread Pool> #8
Thread started: <Thread Pool> #9
Thread finished: <Thread Pool> #5
The thread 'Unknown' (0x5) has exited with code 0 (0x0).
Thread finished: <Thread Pool> #9
The thread 'Unknown' (0x9) has exited with code 0 (0x0).
Thread finished: <Thread Pool> #2
Thread started: <Thread Pool> #10
The thread 'Unknown' (0x2) has exited with code 0 (0x0).

预先感谢

1 个答案:

答案 0 :(得分:0)

问题出在港口。我使用的端口不是公共端口。