我有一个锅炉板Xamarin.Forms跨平台应用程序 . 我不知道允许ANDROID App连接到互联网的设置是什么 . 在UWP中,我必须启用一些功能,现在它可以工作 . 在Android Manifest我启用了“互联网”,但仍然没有运气不确定丢失了什么 .

public MainPage()
    {

        InitializeComponent();

        HttpClient client = new HttpClient();
        CurrentRaceInfo cur_race = new CurrentRaceInfo();
        try
        {
            var cur_racedetail = await client.GetStringAsync("Place URL here");

        }
        catch (Exception e)
        {
            var ooo = e;
            throw;
        }
    }

System.Reflection.TargetInvocationException:调用目标抛出了异常 . ---> System.Net.Http.HttpRequestException:发送请求时发生错误---> System.Net.WebException:错误:ConnectFailure(连接超时)---> System.Net.Sockets.SocketException:Connection时间到
在System.Net.Sockets.Socket.Connect(System.Net.EndPoint remoteEP)[0x000b6] in:0
在System.Net.WebConnection.Connect(System.Net.HttpWebRequest请求)[0x0016d]中:0
---内部异常堆栈跟踪结束---
在System.Net.HttpWebRequest.EndGetResponse(System.IAsyncResult asyncResult)[0x00058] in:0
在System.Threading.Tasks.TaskFactory1 [TResult] .FromAsyncCoreLogic(System.IAsyncResult iar,System.Func2 [T,TResult] endFunction,System.Action1 [T] endAction,System.Threading.Tasks.Task1 [TResult] promise,System.Boolean requiresSynchronization)[0x0000f] in:0
---从抛出异常的先前位置开始的堆栈跟踪结束---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c] in:0
在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务)[0x0003e] in:0
在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x00028] in:0
在System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task任务)[0x00008] in:0
在System.Runtime.CompilerServices.ConfiguredTaskAwaitable1 ConfiguredTaskAwaiter [TResult] .GetResult()[0x00000] in:0 在System.Net.Http.HttpClientHandler d__63.MoveNext()[0x00450] in:0 ---内部异常堆栈跟踪结束--- 在System.Net.Http.HttpClientHandler d__63.MoveNext()[0x004ab] in:0 ---从抛出异常的先前位置开始的堆栈跟踪结束--- 在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c] in:0 在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务)[0x0003e] in:0 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x00028] in:0 在System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task任务)[0x00008] in:0 在System.Runtime.CompilerServices.ConfiguredTaskAwaitable1 ConfiguredTaskAwaiter [TResult] .GetResult()[0x00000] in:0
在System.Net.Http.HttpClient d__49.MoveNext()[0x000ca] in:0
---从抛出异常的先前位置开始的堆栈跟踪结束---
在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c] in:0
在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务)[0x0003e] in:0
在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x00028] in:0
在System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task任务)[0x00008] in:0
在System.Runtime.CompilerServices.ConfiguredTaskAwaitable1 ConfiguredTaskAwaiter [TResult] .GetResult()[0x00000] in:0 在System.Net.Http.HttpClient d__54.MoveNext()[0x0007d] in:0 ---从抛出异常的先前位置开始的堆栈跟踪结束--- 在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c] in:0 在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task任务)[0x0003e] in:0 在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task任务)[0x00028] in:0 在System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(System.Threading.Tasks.Task任务)[0x00008] in:0 在System.Runtime.CompilerServices.TaskAwaiter1 [TResult] .GetResult()[0x00000] in:0
at(wrapper managed-to-native)System.Reflection.MonoMethod:InternalInvoke(System.Reflection.MonoMethod,object,object [],System.Exception&)
在System.Reflection.MonoMethod.Invoke(System.Object obj,System.Reflection.BindingFlags invokeAttr,System.Reflection.Binder binder,System.Object [] parameters,System.Globalization.CultureInfo文化)[0x00032] in:0
---内部异常堆栈跟踪结束---
在System.Reflection.MonoMethod.Invoke(System.Object obj,System.Reflection.BindingFlags invokeAttr,System.Reflection.Binder binder,System.Object [] parameters,System.Globalization.CultureInfo culture)[0x0004b] in:0
在System.Reflection.MethodBase.Invoke(System.Object obj,System.Object [] parameters)[0x00000] in:0
at NInterpret.Interpreter.callAMethod(NInterpret.AMethod m,NInterpret.AType [] ptypes,NInterpret.AType [] genericMethodArgs,System.Collections.Generic.Dictionary2 [TKey,TValue] genericArgsIndex,System.Object [] args,System .Collections.Generic.List1 [T] byRefArgs,Microsoft.FSharp.Core.FSharpOption1 [T] byRefTarget,System.Object target,System.Boolean virtualCall)[0x0049b] in:0 at NInterpret.Interpreter.callMethodReference(System.Collections.Generic.Dictionary2 [TKey,TValue] gargs,Mono.Cecil.MethodReference ms,System.Boolean virtualCall)[0x00384] in:0
在NInterpret.Interpreter.interpretBlock(System.Object [] args,System.Object [] locals,Mono.Cecil.Cil.Instruction initialInstruction,Microsoft.FSharp.Collections.FSharpSet1 [T] inTries,Microsoft.FSharp.Core . FSharpOption1 [T] lastException)[0x00fb7] in:0
在NInterpret.Interpreter.interpretBlock(System.Object [] args,System.Object [] locals,Mono.Cecil.Cil.Instruction initialInstruction,Microsoft.FSharp.Collections.FSharpSet1 [T] inTries,Microsoft.FSharp.Core . FSharpOption1 [T] lastException)[0x0013c] in:0}

我可以通过创建使用VS 2017文件>新建项目> Web>跨平台>移动应用程序(Xamarin.Forms)创建错误>我选择空白项目,在IOS,ANdroid和UWP中放置复选框 . 选择.Net Standard作为代码共享策略 . 按确定 . 设置prject之后我将Android设置为启动项目,将上面的代码放在共享项目MainPage.Xaml.cs中对于模拟器我使用Xamarin Live播放器连接到我的手机它的Android API 24.我设置了一些断点和运行项目 . 然后它会在Client.GetStringAsync()调用上抛出以下错误 . 如前所述,我对UWP有类似的问题,但我所要做的就是启用一些功能并且问题消失了,我相信我会在IOS上遇到类似的问题,但现在只处理1个问题 .