简体   繁体   English

Xamarin 问题初始化 HttpClient

[英]Xamarin issue initialising HttpClient

I have an issue with my Android project in Xamarin when running debugging that has just started occurring.在运行刚刚开始发生的调试时,我在 Xamarin 中的 Android 项目存在问题。 It's just about the first thing that happens after InitializeComponent();这只是InitializeComponent();之后发生的第一件事。 in App.xaml.cs .App.xaml.cs中。 I'm initialising HttpClient as follows:我正在初始化 HttpClient 如下:

static readonly HttpClient client = new HttpClient();

but straight away get the following error message:但立即收到以下错误消息:

{System.InvalidProgramException: Invalid IL code in ObjCRuntime.RuntimeOptions:GetHttpMessageHandler (): IL_0000: ret
  at System.Net.Http.HttpClient.CreateDefaultHandler () [0x00000] in <e329308c7a294b1ebc65b0effd900db2>:0 
  at System.Net.Http.HttpClient..ctor () [0x00000] in <e329308c7a294b1ebc65b0effd900db2>:0 
  at [MYAPP].Web.WebClient..cctor () [0x00000] in [MYAPPPATH]\Web\WebClient.cs:20 }

I can't seem to find any help and support out there so any help much appreciated.我似乎找不到任何帮助和支持,因此非常感谢任何帮助。

Cheers,干杯,

Justin贾斯汀

I can confirm with 99% certainty that it's related to the latest updates of Visual Studio 2019 Community (not sure if this is isolated to just Community).我可以 99% 的确定它与 Visual Studio 2019 社区的最新更新有关(不确定这是否仅与社区隔离)。 I had this exact same issue when I updated from 16.8.x to 16.9.2 and can confirm that it is still present in 16.9.3.当我从 16.8.x 更新到 16.9.2 时,我遇到了完全相同的问题,并且可以确认它仍然存在于 16.9.3 中。 I've got a separate laptop with VS 2019 16.7.6 running the same codebase without issue.我有一台单独的笔记本电脑,带有 VS 2019 16.7.6,运行相同的代码库没有问题。

Unfortunately it appears that there is no way to rollback VS 2019 Community installs.不幸的是,似乎没有办法回滚 VS 2019 社区安装。 Hopefully this helps.希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM