Issues related to Visual Studio 2022 for Windows
Unable to select the MyApp (Unpackaged WinAppSDK)
profile
A Visual Studio issue is preventing the Unpackaged profile if iOS/Android target frameworks are present in the project. In order for the unpackaged profile to be selected, you'll need to edit the Properties/launchSettings.json
file to remove the MyApp (Packaged WinAppSDK)
entry. Once it is removed, select the MyApp (Unpackaged WinAppSDK)
then start the debugging of your app.
An iOS fails to run with No class inheriting from a valid Application Delegate found
When using iOS Hot Restart on Visual Studio 2022, a limitation of the environment prevents an Uno Platform app from starting properly when MAUI Embedding is referenced.
A workaround is to disable MAUI Embedding in the UnoFeatures
of your project.
App builds in Visual Studio 2022 are taking a long time
Take a look at our article in order to ensure that your solution is building and showing intellisense as fast as possible, and to avoid this Visual Studio issue (help the community by upvoting it!) where multi-targeted project libraries always build their full set of targets.
My app is not running as fast as I want
There could be many reasons for being in this situation, but we've built a list of performance tips in this article that you can apply to your app. If you haven't found your answer, open a discussion to tell us about it!
C# Hot Reload troubleshooting
C# Hot Reload is provided by Visual Studio 2022, and there may be occasions where updates are not applied, or the modified code is incorrectly reported as not compiling.
If that is the case:
- Make sure that the top left selector in the C# editor is showing the project head being debugged. For instance, if debugging with
net8.0-desktop
, select thenet8.0-desktop
project. - WebAssembly does not support C# hot reload when debugging the application. You can start the app without the debugger instead.
- Try recompiling the application completely (with the
Rebuild
command)
More troubleshooting information is available in this section.
error NETSDK1148: A referenced assembly was compiled using a newer version of Microsoft.Windows.SDK.NET.dll
See this article to solve this issue.
Deploying an Android app takes a long time
Android deployment requires a few considerations:
- Android physical device
- Make sure to have a good cable (USB 3 or C) to have a good connection
- Avoid debugging through wifi
- Android Emulators
- Use an Android x86_64 emulator. If not, create a new one.
- Ensure that you have either Hyper-V or AEHD enabled. (See Microsoft's documentation)
- Try disabling
Fast Deployment
in your app configuration 1. Open your project properties 1. In the android section search forFast Deployment
1. uncheck all target platforms
My application does not start under WSL
Your application may fail to run under WSL for multiple reasons:
- Your app is in a path that contains spaces and/or characters such as
[
or]
- WSLg has not been installed
- X11 dependencies have not been installed
Legacy issues
The XAML editor shows The type 'page' does not support direct content
message
This issue has been fixed in Visual Studio 17.8 and later.
If you're using an earlier version, XAML Intellisense is not working properly in Visual Studio when the active project is not the UWP one.
To work around this issue, close all XAML editors, open a C# file and select the '[MyApp].Windows' in the top-left drop-down list of the text editor sector. Once selected, re-open the XAML file.
InitializeComponent
or x:Name
variable is not available in code-behind
This issue has been fixed in Visual Studio 17.8 and later.
If you're using an earlier version, Visual Studio does not refresh the intellisense cache properly, causing variables to be incorrectly defined.
To fix this issue, build your project once, close the solution and reopen it.
It is also important to note that Uno Platform uses a multi-project structure, for which each project has to be build individually for errors to disappear from the Error List window (notice the Project column values).
In order to clear the Error List window, build the whole solution completely once. Thereafter, build a specific project and prefer the use of the Output tool window (in the menu View -> Output), taking build messages by order of appearance.
Event handler cannot be added automatically
Event handlers cannot be automatically added using the XAML editor.
A workaround is to use the x:Bind
to events feature. This feature allows to use a simpler syntax like <Button Click="{x:Bind MyClick}" />
and declare a simple method private void MyClick() { }
in the code-behind.
WebAssembly: Hot Reload fails to start with Mixed Content: The page at XXX was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint
This issue is caused by visual studio enforcing https connections for local content. You can work around this by either:
- Removing the https endpoint in the
Properties/launchSettings.json
file - Unchecking the
Use SSL
option in the project's Debug launch profiles - Selecting the project name instead of IISExpress in the toolbar debug icon drop down list
Error MSB3030: Could not copy the file "MyProject.Shared\MainPage.xbf" because it was not found
This issue is present in Visual Studio 17.2 and 17.3, and can be addressed by taking a look at this issue.