我们正在使用 Xamarin Forms 5 和 Visual Studio 2022 构建适用于 iOS 和 Android 的移动应用程序。当我们向任何 api 发出 Post 请求时,我们自己的外部 api 总是会返回:
Xamarin.PreBuilt.iOS[3728:2199180] Xamarin.iOS: Received unhandled ObjectiveC exception: NSMallocException Failed to grow buffer
GET 请求工作正常。我搜索了 Google 和 StackOverflow 但找不到任何帮助。我尝试增加 HttpClient.MaxResponseContentBufferSize 没有任何区别。
现在的应用程序非常简单,一个页面有一个测试按钮。后台代码如下:
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private async void Button_Clicked(object sender, EventArgs e)
{
var client = new HttpClient();
client.BaseAddress = new Uri("https://ptsv2.com/");
string jsonData = @"{}";
var content = new StringContent(jsonData, Encoding.UTF8, "application/json");
HttpResponseMessage …Run Code Online (Sandbox Code Playgroud)