Why won't .NET MAUI Run as "Windows Machine" On Different Development PCs

1.7k views Asked by At

I have a MAUI application that I put into source control; then pulled down and attempt to develop on a different machine; on the second machine, in Visual Studio 2022 I no longer had the option to run "Windows Machine" it was replace with the name of the project and it wouldn't run it attempts to start but breaks in App.g.i.cs with the message

System.DllNotFoundException: 'Unable to load DLL 'Microsoft.ui.xaml.dll' or one of its dependencies: The specified module could not be found. (0x8007007E)'

How do I setup a MAUI application such that I can run it on different development PCs?

Steps to Replicate / Steps to Confirm Issue

To confirm the issue / attempt to see what the difference is I did the following

  • Machine 1: Create MAUI App from Template (no changes); confirm "Windows Machine" option for debugging; and it runs as expected
  • Machine 2: Create MAUI App from Template (no changes); confirm "Windows Machine" option for debugging; and it runs as expected
  • Copy Code from Machine 1 to Machine 2: Windows Machine option not available; application won't start up with above exception
  • Copy Code from Machine 2 to Machine 1: Windows Machine option not available; application won't start up with above exception
  • Use Git to compare the two applications: looks like only difference is OpenSans-Regular.ttf and OpenSans-Semibold.ttf and the ApplicationIdGuid ... note if change those values (copy files, change guid) it still won't permit Machine 1 code to have "Windows Machine" Option on Machine 2

Assumption: I'm assuming there is some difference between the two machines that is causing this; but I'm not sure how to determine that difference and resolve; both are running VS2022 17.3.6 64-bit; Xamarin 17.3.0.296; .NET Core 6

It seems the symptom that show the issue is that the MauiApp showing that "Windows Machine" as an optio to run up the application; if the App was created on the Machine you get that; but if you pass that code to another machine you see the csproj name and get this exception

Desired Outcome: My goal here is to have a single code base, committed in Git, that I can develop on two different machines with a MAUI App; no worries if there are settings or similar to support; or if one machine needs updates; just how to determine and get to that state is the issue / question.

Any help on resolution; or what that would happen (note: all non-Maui apps work across these two machines; console apps, windows services, web api, web app etc... commit on one; run on the other; it is only Maui apps having this difficulty)

1

There are 1 answers

1
ChrisHDog On

Resolution: launchSettings.json not put into source control; copy launchSettings.json and everything works as expected

It looks like the issue here was less about the machine this was running on; and more that launchSettings.json were not on the target machine when transferring code

I copied the launchSettings.json from the template created to the target machine and things worked as expected from there.