gpt4 book ai didi

c# - Xamarin.Forms 和 ServiceStack 异常 - 无法绑定(bind)到方法 'CertStoreLookup'

转载 作者:行者123 更新时间:2023-11-30 00:07:42 30 4
gpt4 key购买 nike

我们有一个 Xamarin.Forms android 和 ios 应用程序,多年来一直表现良好。最新版本自 2017 年初开始投入生产,很少发生崩溃。直到最近!

我们的一个 android 客户端在连接到我们的 ServiceStack 支持的 API 服务时开始出现异常。现在我们的 API 服务自应用程序部署(2017 年 1 月)以来没有更改,我们在 2017 年 12 月才开始收到这些错误。

在其设备上登录的应用程序的详细信息揭示了以下内容。

Exception: The type initializer for 'System.AndroidPlatform' threw an exception.StackTrace: at System.Net.WebProxy.CreateDefaultProxy () [0x00000] in <10a067eff09446018662189377d200e9>:0 
at System.Net.Configuration.DefaultProxySectionInternal.GetSystemWebProxy () [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.Configuration.DefaultProxySectionInternal.GetDefaultProxy_UsingOldMonoCode () [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.Configuration.DefaultProxySectionInternal.GetSection () [0x00015] in <10a067eff09446018662189377d200e9>:0
at System.Net.WebRequest.get_InternalDefaultWebProxy () [0x00022] in <10a067eff09446018662189377d200e9>:0
at System.Net.HttpWebRequest..ctor (System.Uri uri) [0x0008d] in <10a067eff09446018662189377d200e9>:0
at (wrapper remoting-invoke-with-check) System.Net.HttpWebRequest:.ctor (System.Uri)
at System.Net.HttpRequestCreator.Create (System.Uri uri) [0x00000] in <10a067eff09446018662189377d200e9>:0
at System.Net.WebRequest.Create (System.Uri requestUri, System.Boolean useUriBase) [0x00091] in <10a067eff09446018662189377d200e9>:0
at System.Net.WebRequest.Create (System.String requestUriString) [0x00014] in <10a067eff09446018662189377d200e9>:0
at ServiceStack.PclExport.CreateWebRequest (System.String requestUri, System.Nullable`1[T] emulateHttpViaPost) [0x00000] in <0c56e395a4c44995b59b57d9e7ca7331>:0
at ServiceStack.ServiceClientBase.PrepareWebRequest (System.String httpMethod, System.String requestUri, System.Object request, System.Action`1[T] sendRequestAction) [0x0004e] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.SendRequest (System.String httpMethod, System.String requestUri, System.Object request) [0x00014] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.Send[TResponse] (System.String httpMethod, System.String relativeOrAbsoluteUrl, System.Object request) [0x00075] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.Get[TResponse] (System.String relativeOrAbsoluteUrl) [0x00000] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at ServiceStack.ServiceClientBase.Get[TResponse] (ServiceStack.IReturn`1[T] requestDto) [0x00012] in <d92dd3dd0cd44141a8ac071b8dc829af>:0
at [OUR APP].PCL.Services.Agent.IsAwake () [0x00013] in <cb1d96a8f02e4d9f92152b248e31ee23>:0
Source: System
Has Inner Exceptions: True

Inner Exception 1: Couldn't bind to method 'CertStoreLookup'.
StackTrace: at System.Delegate.GetCandidateMethod (System.Type type, System.Type target, System.String method, System.Reflection.BindingFlags bflags, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x000f9] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.Delegate.CreateDelegate (System.Type type, System.Type target, System.String method, System.Boolean ignoreCase, System.Boolean throwOnBindFailure) [0x00014] in <657aa8fea4454dc898a9e5f379c58734>:0
at System.AndroidPlatform..cctor () [0x0002d] in <10a067eff09446018662189377d200e9>:0
Source: mscorlib
Has Inner Exceptions: False

25/01/18 11:01:19 IsAwake The type initializer for 'System.AndroidPlatform' threw an exception. Endpoint http://OURENDPOINT/
25/01/18 11:01:18 Sync Started

我已经能够重现此错误,但仅限于发布版本。使用共享运行时框架时,它在 DEBUG 模式下一切正常。因此,这让我认为 Android 的发布构建包正在删除 Android 需要的东西,但我终究无法弄清楚它是什么。

版本信息

VS2017 15.5.6
Xamarin 4.8.0.760
Xamarin.Android SDK 8.1.5.0
Xamarin.Forms v1.5.0.6447 (in PROD)
ServiceStack.Client (PCL proj via NuGet) 4.0.40 (in PROD)
Installed SDK's
8.0.0(26), 7.1.1(25), 7.0(24), 6.0(23), 5.01(21), 4.4.2(19),

构建配置

Target Framework: 6.0 (v23)
Minimum SDK: 4.0.3 (v15)

**DEBUG**
Use Shared Runtime : true
Use Fast Deploy : false
Linking: SDK Assemblies only

**RELEASE**
Use Shared Runtime : false
Use Fast Deploy : false
Linking: none

我一直在尝试很多事情..我已将目标框架更新为 7.1,最低为 5.0,删除了所有 Xamarin 和 ServiceStack 引用,然后安装了针对框架级别的新引用。

一切都在 DEBUG 中有效,但在 RELEASE 中无效。

非常感谢任何人可以提供的帮助..

TIA。

编辑

执行@mahmoud-kamel 建议的步骤后,我在 RELEASE 构建中遇到以下错误。

Severity    Code    Description Project File    Line    Source  Suppression State
Error The "LinkAssemblies" task failed unexpectedly.
Mono.Linker.MarkException: Error processing method: 'System.Void Android.Support.V4.App.FragmentActivity::n_OnRequestPermissionsResult_IarrayLjava_lang_String_arrayI(System.IntPtr,System.IntPtr,System.Int32,System.IntPtr,System.IntPtr)' in assembly: 'Xamarin.Android.Support.Fragment.dll' ---> Mono.Cecil.ResolutionException: Failed to resolve System.Void Android.App.Activity::OnRequestPermissionsResult(System.Int32,System.String[],Android.Content.PM.Permission[])
at Mono.Linker.Steps.MarkStep.HandleUnresolvedMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkMethod(MethodReference reference)
at Mono.Linker.Steps.MarkStep.MarkInstruction(Instruction instruction)
at Mono.Linker.Steps.MarkStep.MarkMethodBody(MethodBody body)
at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)
at Mono.Linker.Steps.MarkStep.ProcessQueue()
--- End of inner exception stack trace ---
at Mono.Linker.Steps.MarkStep.ProcessQueue()
at Mono.Linker.Steps.MarkStep.ProcessEntireQueue()
at Mono.Linker.Steps.MarkStep.Process()
at Mono.Linker.Steps.MarkStep.Process(LinkContext context)
at Mono.Linker.Pipeline.Process(LinkContext context)
at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)
at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
at Xamarin.Android.Tasks.LinkAssemblies.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [OUR APP].DroidApp C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1696 Build

最佳答案

事实证明这是项目引用的程序集不匹配。

查看bin/debug和bin/release文件夹下System.dll的内部结构,对比VS模板新建项目,我们可以确定项目升级后使用最新版本SDK、MSBuild 未从正确的 ReferenceAssemblies 文件夹位置检索 SYSTEM.dll。

在我的电脑上搜索“ReferenceAssemblies”会找到大约 4 个位置!

正确的位置(在我的电脑上)是以下文件夹,其中包含 Android 版本号文件夹(例如“v8.0”)。

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\

我希望这对某人有所帮助,并为他们节省我花在这上面的时间!

关于c# - Xamarin.Forms 和 ServiceStack 异常 - 无法绑定(bind)到方法 'CertStoreLookup',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48696263/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com