Base solution for your next web application
Open Closed

Bug Report: Crash in MAUI MainLayout due to null QR Login MenuItem #12468


User avatar
0
sailoper created
  1. Main page layout doesn't load because qrMenuItem can be null Issue: When QR Login is disabled (IsQrLoginEnabled is false), the method AddQrLoginMenuItem() returns null. This null value is still added to the _menuItems list.

Later, when FilterAuthorizedMenuItems() tries to process this list, it crashes with "Object reference not set to an instance of an object" error.

Because of this, MainLayout does not render at all and the screen stays empty. I spent the whole day trying to figure this out because there was no visible error on the screen. I'm also not very experienced with MAUI yet, and I only realized how to read the actual error message at the end of the day.

Suggested fix: Only add qrMenuItem if it's not null, like this:

var qrMenuItem = AddQrLoginMenuItem(); _menuItems = new List<NavigationMenuItem> { ... };

if (qrMenuItem != null) { _menuItems.Add(qrMenuItem); }

  1. Wrong IP address for Android emulator

By default, DebugServerIpAddresses.Current is set to "192.168.1.12". But for Android emulator, it should be "10.0.2.2".

Yes, it's mentioned in the docs, but it's still better to set it correctly by default so developers don't waste time figuring it out.

  1. Wrong port and protocol in ApiUrlConfig

In ApiUrlConfig.cs, the default URL is:

"http://localhost:44302/"

But the Host project runs on port 44301 with HTTPS. So this causes API requests to fail unless we manually fix it.

It should be:

"https://localhost:44301/"

Summary:

  • qrMenuItem causes crash → should check for null before adding
  • IP address should be 10.0.2.2 for emulator
  • API URL should use correct port and HTTPS
Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

1 Answer(s)
  • User Avatar
    0
    oguzhanagir created
    Support Team

    Hi @sailoper

    Thank you for your feedback. These issues have been resolved in the development environment. They will be addressed in the upcoming version 14.2, which will be released soon.

    Additionally, the MAUI MVC project is now generated to use the default port of the MVC project, which is set to "https://localhost:44302/". Similarly, this also applies to the Host project, which is now generated to use the default MAUI Host URL: "https://localhost:44301/".

    For DebugServerIpAddresses, it is more appropriate to use the IP address of the device running locally, as this is required in the development environment. This value replaces the localhost URL for accessing the API.

    Related Changes

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)