在 xamarin 中,我使用 refit 库调用 api。我已按照说明进行操作,但是在调用异常 api 时返回。不知道我的棱镜组合会不会有影响?我已经调用了手动 api,但它也不起作用我也在互联网上咨询过,但似乎一切仍然不起作用。在高级 Android 选项中,我将 HttpClient 实现设置为 Android,SSL / TSL 实现为 Default (Native TLS 1.2+) 。我能帮帮我吗?
public interface IMakeUpApi
{
[Get("/api/v2/items")]
Task<string> GetMakeups();
}
在 MainPageViewModel
var apiResponse = RestService.For<IMakeUpApi>("https://qiita.com");
var makeups = await apiResponse.GetMakeups();
错误
System.Net.Http.HttpRequestException Message=mono-io-layer-error (-1) Source=mscorlib StackTrace:在 System.Net.Http.ConnectHelper.ConnectAsync(System.String 主机,System.Int32 端口,System.Threading。 CancellationToken cancelToken) [0x00180] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ ConnectHelper.cs:84 在 System.Threading.Tasks.ValueTask
1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x000ea] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:371 at System.Threading.Tasks.ValueTask
1[TResult].get_Result () [0x0001b] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/ src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 在 System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (System.Threading.Tasks.ValueTask1[TResult] creationTask) [0x000a2] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:529 at System.Threading.Tasks.ValueTask
1[TResult].get_Result () [0x0001b] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks /ValueTask.cs:813 在 System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage 请求,System.Boolean doRequestAuth,System.Threading.CancellationToken cancelToken)[0x0003f] 在 /Users/builder/jenkins/workspace /archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:284 在 System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage 请求,System.Threading.CancellationToken cancelToken) [0x00070] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.网。Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs:32 在 System.Net.Http.HttpClient.FinishSendAsyncUnbuffered (System.Threading.Tasks.Task1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x000b3] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:531 at Refit.RequestBuilderImplementation+<>c__DisplayClass14_0
2[T,TBody].b__0(System.Net.Http.HttpClient 客户端,System.Threading.CancellationToken ct,System.Object[] paramList)[0x00188] in :0 at TestApp.ViewModels.MainPageViewModel.Navigate () [0x0003b ] 在 E:\H\Xamarin\TestApp\TestApp\TestApp\ViewModels\MainPageViewModel.cs:58 在 System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object 状态) [0x00000] 在 /Users/builder/ jenkins/workspace/archive-mono/2019-08/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 at Android.App.SyncContext+<>c__DisplayClass2_0.b__0 () [0x00000 ] 在:0 在 Java.Lang.Thread+RunnableImplementor.Run () [0x00008] 在:0 在 Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] 在 :0 在 (wrapper动态方法)Android。Runtime.DynamicMethodNameCounter.39(intptr,intptr)
细节异常
- ex {System.Net.Http.HttpRequestException: mono-io-layer-error (-1) ---> System.Net.Sockets.SocketException: 在 System.Net.Http 的 mono-io-layer-error (-1) /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx 中的 .ConnectHelper.ConnectAsync(System.String 主机,System.Int32 端口,System.Threading.CancellationToken cancelToken)[0x000c8] /src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:65 ---内部异常堆栈跟踪结束---在 System.Net.Http.ConnectHelper.ConnectAsync (System.String主机,System.Int32 端口,System.Threading.CancellationToken cancelToken) [0x00180] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http /src/System/Net/Http/SocketsHttpHandler/ConnectHelper.cs:84 在 System.Threading.Tasks。价值任务
1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at System.Net.Http.HttpConnectionPool.CreateConnectionAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) [0x000ea] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:371 at System.Threading.Tasks.ValueTask
1[TResult].get_Result () [0x0001b] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks /ValueTask.cs:813 在 System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync (System.Threading.Tasks.ValueTask1[TResult] creationTask) [0x000a2] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:529 at System.Threading.Tasks.ValueTask
1[TResult].get_Result () [0x0001b] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks /ValueTask.cs:813 在 System.Net.Http.HttpConnectionPool.SendWithRetryAsync (System.Net.Http.HttpRequestMessage 请求,System.Boolean doRequestAuth,System.Threading.CancellationToken cancelToken)[0x0003f] 在 /Users/builder/jenkins/workspace /archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs:284 在 System.Net.Http.RedirectHandler.SendAsync (System.Net.Http.HttpRequestMessage 请求,System.Threading.CancellationToken cancelToken) [0x00070] 在 /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.网。Http/src/System/Net/Http/SocketsHttpHandler/RedirectHandler.cs:32 在 System.Net.Http.HttpClient.FinishSendAsyncUnbuffered (System.Threading.Tasks.Task1[TResult] sendTask, System.Net.Http.HttpRequestMessage request, System.Threading.CancellationTokenSource cts, System.Boolean disposeCts) [0x000b3] in /Users/builder/jenkins/workspace/archive-mono/2019-08/android/release/external/corefx/src/System.Net.Http/src/System/Net/Http/HttpClient.cs:531 at Refit.RequestBuilderImplementation+<>c__DisplayClass14_0
2[T,TBody].b__0(System.Net.Http.HttpClient 客户端,System.Threading.CancellationToken ct,System.Object[] paramList)[0x00188] in :0 at TestApp.ViewModels.MainPageViewModel.Navigate () [0x00044 ] 在 E:\H\Xamarin\TestApp\TestApp\TestApp\ViewModels\MainPageViewModel.cs:60 } System.Net.Http.HttpRequestException- 基础 {System.Exception} System.Exception
- 数据 {System.Collections.ListDictionaryInternal} System.Collections.ListDictionaryInternal HResult -2147467259 int HelpLink (null) 字符串
- InnerException {System.Net.Sockets.SocketException} System.Net.Sockets.SocketException
- 基础 {System.ComponentModel.Win32Exception} System.ComponentModel.Win32Exception
- 基础 {System.Runtime.InteropServices.ExternalException} System.Runtime.InteropServices.ExternalException
- 基础 {System.SystemException} System.SystemException
- 基础 {System.Exception} System.Exception
- 数据 {System.Collections.ListDictionaryInternal} System.Collections.ListDictionaryInternal HResult -2147467259 int HelpLink (null) string InnerException (null) System.Exception Message "mono-io-layer-error (-1)" string Source "mscorlib" string StackTrace "在 System.Net.Http.ConnectHelper.ConnectAsync (System.String 主机、System.Int32 端口、System.Threa..." 字符串
- TargetSite {System.Reflection.RuntimeMethodInfo} System.Reflection.RuntimeMethodInfo
- 基础 {System.Reflection.MethodInfo} System.Reflection.MethodInfo 属性 System.Reflection.MethodAttributes.FamANDAssem | System.Reflection.MethodAttributes.Family | System.Reflection.MethodAttributes.HideBySig System.Reflection.MethodAttributes CallingConvention System.Reflection.CallingConventions.HasThis | System.Reflection.CallingConventions.Standard System.Reflection.CallingConventions ContainsGenericParameters false bool
- DeclaringType {System.RuntimeType} System.RuntimeType IsGenericMethod false bool IsGenericMethodDefinition false bool IsSecurityCritical true bool IsSecuritySafeCritical true bool IsSecurityTransparent false bool MetadataToken 100680451 int
- MethodHandle {System.RuntimeMethodHandle} System.RuntimeMethodHandle
- 模块 {System.Reflection.RuntimeModule} System.Reflection.RuntimeModule 名称“Throw”字符串
- ReflectedType {System.RuntimeType} System.RuntimeType
- ReturnParameter {System.Reflection.RuntimeParameterInfo} System.Reflection.RuntimeParameterInfo
- ReturnType {System.RuntimeType} System.RuntimeType
- ReturnTypeCustomAttributes {System.Reflection.RuntimeParameterInfo} System.Reflection.RuntimeParameterInfo
- 非公共成员
BindingFlags System.Reflection.BindingFlags.Default System.Reflection.BindingFlags- ReflectedTypeInternal {System.RuntimeType} System.RuntimeType mhandle 0xffffffff91fc61a8 System.IntPtr 名称“Throw”字符串
- reftype {System.RuntimeType} System.RuntimeType
- 静态成员
- 非公共成员
ErrorCode -1 int NativeErrorCode -1 int- 非公共成员
ErrorCode -1 int Message "mono-io-layer-error (-1)" string SocketErrorCode System.Net.Sockets.SocketError.SocketError System.Net.Sockets.SocketError- 非公共成员
消息“mono-io-layer-error (-1)”字符串源“mscorlib”字符串 StackTrace“在 System.Net.Http.ConnectHelper.ConnectAsync(System.String 主机,System.Int32 端口,System.Threa …“ 细绳- TargetSite {System.Reflection.RuntimeMethodInfo} System.Reflection.RuntimeMethodInfo
- 静态成员
- 非公共成员
_COMPlusExceptionCode -532462766 int- s_EDILock {object} 对象
- 非公共成员
IsTransient System.NotImplementedException:方法或操作未实现。bool RemoteStackTrace (null) string _HResult -2147467259 int _className "System.Net.Http.HttpRequestException" string- _data {System.Collections.ListDictionaryInternal} System.Collections.ListDictionaryInternal _dynamicMethods(空)对象 _helpURL(空)字符串
- _innerException {System.Net.Sockets.SocketException} System.Net.Sockets.SocketException _message "mono-io-layer-error (-1)" string _remoteStackIndex 0 int _remoteStackTraceString (null) string
- _safeSerializationManager {System.Runtime.Serialization.SafeSerializationManager} System.Runtime.Serialization.SafeSerializationManager _source "mscorlib" 字符串
- _stackTrace {System.IntPtr[18]} System.IntPtr[] _stackTraceString (null) 字符串
- 捕获跟踪 {System.Diagnostics.StackTrace[7]} System.Diagnostics.StackTrace[] 捕获_in_unmanaged 0 int native_trace_ips (null) System.IntPtr[]