An unhandled error has occured Maui Blazor on physical iphone

250 views Asked by At

I successful Debug my Maui Blazor to local device which an iPhone (usb cable), However when i click into my app i got an error "An unhandled error has occured. Reload". How can I see the output of the error. Im using visual studio 22 for windows Thanks

i tried chrome://inspect/#devices but it does not show my iphone to inspect. here is the code in the index.razor

        @if (dataObjects is not null)
        {

            @foreach (var product in dataObjects)
            {
                @if (@product.Sl.HasValue)
                {
                    <tr>
                        <td>Số Lượng: @product.Sl</td>

                    </tr>
                    <tr>
                        <td>Tiền Mặt: @Math.Round(product.TienMat.Value, 2).ToString("n2")</td>

                    </tr>
                    <tr>
                        <td>
                            Thẻ:
                            @if (@product.The.HasValue)
                                @Math.Round(product.The.Value, 2).ToString("n2")


                            </td>

                        </tr>
                    <tr>
                        <td> Lợi Nhuận: @Math.Round(product.LoiNhuan.Value, 2).ToString("n2")</td>
                    </tr>
                }


            }
        }

<button @onclick="OnRefreshClicked">Refresh</button>

@code {
    private List<ThongTinBanHangTrongNgay> dataObjects;
    private HttpClient client;
    private UltiHelps ultiHelps;

    private async Task OnRefreshClicked()
    {
        client = new HttpClient();
        TimeZoneInfo zone = TimeZoneInfo.FindSystemTimeZoneById("AUS Eastern Standard Time");
        DateTime australianNow = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, zone);
        String TodayDate = australianNow.ToString("yyyy-MM-dd");
        HttpResponseMessage response = await client.GetAsync("XXXXX");
        //string json = await response.Content.ReadAsStringAsync();
        // Khi dữ liệu được trả về, hãy sử dụng phương thức JsonConvert.DeserializeObject() để chuyển đổi dữ liệu JSON thành một đối tượng DataTable
        if (response.IsSuccessStatusCode)
        {
            string json = await response.Content.ReadAsStringAsync();
            dataObjects = JsonConvert.DeserializeObject<List<ThongTinBanHangTrongNgay>>(json);
            //dataObjects._products = JsonSerializer.Deserialize<DataTable>(json);

        }
    }
}
1

There are 1 answers

0
Liqun Shen-MSFT On BEST ANSWER

I can reproduce this issue. The error should be 'The time zone ID 'AUS Eastern Standard Time' was not found on the local computer'. It only happens on iOS.

The workaround is, if Windows time zones don't work, you may try using IANA time zones.

So if you use Australia/Melbourne or Australia/Sydney

TimeZoneInfo zone = TimeZoneInfo.FindSystemTimeZoneById("Australia/Melbourne");

Then it works fine.

For more info, you could refer to Converting Microsoft Timezone to standards timezone data in rails and How to translate between Windows and IANA time zones?.

Hope it helps!