dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.12k stars 1.73k forks source link

MAUI Blazor for Windows - Remote Debugging: "ERR_ADDRESS_INVALID" #9449

Open miguelkmarques opened 2 years ago

miguelkmarques commented 2 years ago

Description

I'm trying to Debug a MAUI Blazor App for Windows only on a Remote machine. I have added on launchSettings.json a new profile to Deploy and Debug on another device, using Visual Studio 2022 Remote Debugger.

The app is deployed to the remote device successfully and after the app opens the BlazorWebView doesn't work with the error "ERR_ADDRESS_INVALID":

Screenshot 2022-08-15 214507

Remote Debugging with the template of MAUI Project with no Blazor works perfectly well.

Unfortunately on the Debug Output there are no errors or exceptions when executing, so i have no clue as to what is happening because when i execute using my local machine, it works normally. I have tried with 2 different devices, running Windows 11 x64 and both had the same issue, but when i publish the application for Windows following Publish a .NET MAUI app for Windows and install on the device that i was trying to Remote Debug, the application works normally, the issue appears to be just when the application is deployed from Visual Studio.

For this project that i'm working on, i really need to Debug our application using a Remote Device, so without this possibility it becomes time consuming, because i have to publish the application, copy and paste to another device, install and analyse the logs generated.

Steps to Reproduce

Visual Studio 2022 17.4.0 Preview 1.0

  1. Create a project with the Blazor MAUI Template
  2. Remove all the TargetFrameworks tags from .csproj and keep just the net6.0-windows10.0.19041.0
  3. On lauch launchSettings.json, add a new profile to deploy to a remote device Example:
    {
    "profiles": {
    "Windows Machine": {
      "commandName": "MsixPackage",
      "nativeDebugging": false
    },
    "Windows Remote": {
      "commandName": "MsixPackage",
      "nativeDebugging": false,
      "remoteDebugEnabled": true,
      "remoteDebugMachine": "192.168.137.1",
      "authenticationMode": "None"
    }
    }
    }
  4. On the another device (Running Windows 11 21H2 x64), start the Visual Studio 2022 Remote Debugger (usually i'm using without Authentication)
  5. Start Debugging from Visual Studio 2022 using the Remote Profile
  6. The app should be deployed and opened on the remote Device
  7. The BlazorWebView component doesn't work

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

windows10.0.19041.0

Did you find any workaround?

No response

Relevant log output

No logs found for this issue.
miguelkmarques commented 2 years ago

Since our project is just for Windows, i decided to try the Blazor App inside a dotnet 6.0 WPF Project with a Windows Application Packaging Project for side-loading. By following this Tutorial Build a Windows Presentation Foundation (WPF) Blazor app, which uses the nuget package Microsoft.AspNetCore.Components.WebView.Wpf. And i found that deploying the App from Visual Studio to Debug on a Remote machine, the BlazorWebView component on MainWindow.xaml works perfectly well! Unfortunately i could not make the BlazorWebView to work on the MAUI project on Remote debugging. For now we are going to use WPF.

ghost commented 1 year ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

danroth27 commented 1 year ago

Hi folks. For those that are hitting this issue, could you please share with us some details about why you are remote debugging your .NET MAUI Blazor app? We're trying to understand how many folks are likely to be impacted by this issue. Thanks!

miguelkmarques commented 1 year ago

In our case, it's because we are developing an application for Windows devices that have Mobile Broadband Radio capabilities with SIM Card or eSIM, to make use of Mobile Broadband API. The app targets multiple types of devices (x64 and ARM64) and phone carriers, since it differs based on the carrier as well. The possibility to remote debug is to easily use your main company computer that have access to corporate network and git repository to develop and debug on multiple devices with ease, otherwise we would need to install Visual Studio on every machine and always copy the code to debug, and we need to debug with low-end devices with limited RAM for example, running Visual Studio would be difficult. Thanks!

homeyf commented 1 year ago

Verified this issue with Visual Studio Enterprise 17.7.0 Preview 2.0. Can repro on MauiBlazor project.

stevencreaney commented 12 months ago

Hi folks. For those that are hitting this issue, could you please share with us some details about why you are remote debugging your .NET MAUI Blazor app? We're trying to understand how many folks are likely to be impacted by this issue. Thanks!

We are using the remote debugger for testing Touch Screen devices. We've also confirmed this issue on latest version of net8 RC and VS2022 Preview.

Eilon commented 10 months ago

Confirmed this repros on my machine too.

One thing I suspected was that the wwwroot folder was somehow not getting published, but I see it on the remote machine. Will debug some more.

Eilon commented 10 months ago

I'm still not sure I've fully understood things, but here's what I think I've found for BlazorWebView on .NET MAUI Windows on WinUI in this code:

  1. There are 3 ways of detecting what's on disk as part of a WinUI packaged app:
    1. Start with a base path (such as Package.Current.InstalledLocation.Path) and use regular good old System.IO to find the file you want using a relative assetPath. This has various APIs to check what's on disk without throwing.
    2. Use Package.Current.InstalledLocation.OpenStreamForReadAsync(assetPath). This API immediately throws if the file doesn't exist.
    3. Use await Package.Current.InstalledLocation.TryGetItemAsync(assetPath). This API returns null if the file doesn't exist, and otherwise returns the item
  2. For unpackaged apps it always uses (i), but relative to AppContext.BaseDirectory (because there's no 'package location')
  3. For packaged apps it uses a combination of (iii) to check if the file exists, and if it exists, then it uses (ii) to read the file.
  4. But it seems that we could probably just always use (i) for packaged and unpackaged and it should always work.

Apparently in the Remote Debugging scenario, (ii) and/or (iii) do not seem to work as expected (or, at least, not as we expected).

I'm not sure why we didn't use option (i) for all scenarios to begin with. It might have been because we wanted to use the most WinUI-ish APIs available. Or maybe we found a case where we had to use the WinUI Storage APIs (but so far I can't find a case where it's required - and we do have a case where it doesn't work).

TobiWhatever commented 8 months ago

Running into the same issue with our .NET MAUI app with Blazor components, using Visual Studio Enterprise 17.8.6. Happens with a Release build as well.