- Notifications
You must be signed in to change notification settings - Fork747
Modernize your UWP app with preview UWP support for .NET 9 and Native AOT#9983
-
Hi everyone! We recently announced preview UWP support for .NET 9, described in detail on the #ifdef Windows blog here:Modernize your UWP app with preview UWP support for .NET 9 and Native AOT. This is an effort to help you with the following:
🚨 Please use this post to provide community feedback, ask questions, and discuss preview UWP support for .NET 9. 🚨 If you hit any issues while trying it out, use the following channels to report them:
Thank you, and we're looking forward to hearing from you! |
BetaWas this translation helpful?Give feedback.
All reactions
👍 17❤️ 13
Replies: 43 comments 133 replies
-
This is amazing, you've really made my day with this announcement. The application I develop has been stuck waiting for InkCanvas support in WinUI 3, and gradually a few of our libraries have been dropping .net standard 2.0 support, leaving us to maintain our own forks. I have a small question regarding ARM64 support as I'm using a Surface Pro 11 as my main development machine. The "Project Templates for UWP projects targeting .net 9 and Native AOT" VSIX in the blog doesn't seem to support ARM64 versions of Visual Studio, is there a chance that we'll see support for that in the future? Additionally, I'm curious to know if the support for .net 9 means that we'll be able to debug on ARM64 natively. At the moment I'm compiling to X64 and it works well, but it would be nice to get rid of the emulation layer if possible, as I can't currently run the app on ARM64 natively without a .NET Native build. Again, thank you all SO... SO MUCH. |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 3
-
Sounds like a template issue. Nothing prevents you from creating the project from scratch or copying the template project created from another device.
Yes. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Currently my project builds faster using .NET Native in Release configuration than using .NET 9 with AOT in Debug configuration. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Mmh that doesn't sound right. Are you able to provide a verbose binlog or record a trace? FYI@manodasanW |
BetaWas this translation helpful?Give feedback.
All reactions
-
Sure, how can I collect them? |
BetaWas this translation helpful?Give feedback.
All reactions
-
https://github.com/dotnet/msbuild/blob/main/documentation/wiki/Binary-Log.md#creating-a-binary-log-during-a-build this way I think. That is:
|
BetaWas this translation helpful?Give feedback.
All reactions
-
Can't build with |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@FrayxRulez can youfollow these steps first, and share the resulting .zip? Should be a good place to start. Feel free to DM that on Discord if you don't want to share it here publicly (in case it contains any private info from your machine). Thank you! 🙂 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
First, thank you very much!
I'm getting an "Operation is not valid due to the current state of the object." error when creating the project from the VS template. I'm not sure if the following issue is because of this error. App won't build with the following. I tried installing the 8.0.4 System.Text.Json, but can't resolve the error. NETSDK1060Error reading assets file: Error loading lock file 'C:\Users\Carlo\source\repos\APP UWP with NET 9 Test 1\APP UWP with NET 9 Test 1\obj\project.assets.json' : Could not load file or assembly 'System.Text.Json, Version=8.0.0.4, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.APP UWP with NET 9 Test 1C:\Program Files\dotnet\sdk\9.0.100-rc.2.24466.31\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets266 |
BetaWas this translation helpful?Give feedback.
All reactions
-
Got me past that error :) A new one popped up though: Deploy is checked in Configuration Manager. I've tried to hunt down the .appx package. But these are usually generated at build and difficult to find. Closest I came was: C++ Runtime v11.0 framework package for Desktop Bridge (Project Centennial) Also installed Visual Studio 2012 (VC++ 11.0) Update 4. And tried to add it as a dependency in Package.appmanifest.xml. No change though. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Are you 100% sure you're on VS 17.12 P2, and you've follow exactly all other instructions in the blog post (eg. including that line to exclude WebView2, etc.)? I have not seen this issue before, but it seems like you're missing an SDK reference, which should be added by default in that new preview of VS. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Hmm. There shouldn't really be any differences with community or enterprise should it when it comes to SDK references? I can build up a clean VM tomorrow and rebuild the enviroment from scratch.
|
BetaWas this translation helpful?Give feedback.
All reactions
-
Created a fresh VM.
I can build the templates on a fresh VM, so something about the problem laying between the keyboard and the chair I guess. The build process on the VM also required the WindowsSdkPackageVersion to be set in the .csproj file. But the key difference between the VM and my actual computer seems to be the version of Microsoft.VCLibs for UWPDesktop it tries to deploy. The VM tried to deploy 140.00 and succeeded. My computer tries to deploy 110.00 and fails because the package is missing. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Did you forget to install the C++/UWP workload/components in VS? I wonder if you're missing 140.00 on your computer. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Will it be supported on Xbox? |
BetaWas this translation helpful?Give feedback.
All reactions
-
It's not officially supported at the moment (though it will work fine on Xbox if you try it). If you have specific use cases for why you'd need official support for Xbox, please let us know about them! 🙂 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I am working on background music player for Xbox, and it would be really nice to use .NET5+ libraries and features. Official support would be great to ensure that all features will be supported on Xbox. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
I would be curious to know what support would look like.Stride was in the process of removing our old implementation of UWP due to it not working for us since we updated to .NET 6. We have someplanned work to create a testing branch of Stride using .NET 9 so getting UWP working again would be pretty cool to test out. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
I also am stuck on UWP mostly for XBox support. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I tried out the preview and it is overall working great! Here are some issues I observe (I use a UWP app + win32 helper with a separate packaging project)
|
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Thank you for the feedback!
Update: (thanks to@ahmed605 for the help investigating this), so the resw files not being accessible is actually expected. It worked for UWP previously because in that case both projects were packaging projects, so their resources were automatically combined. Here instead with the .NET 9 tooling, the app project is just a normal .NET project, so the resources are no longer merged automatically. This is the same with a packaged WinUI 3 project, it's not just a UWP .NET 9 issue. It might be interesting to look into adding some support for making this automatic in the future, both for UWP and WinUI 3, but for now yeah this behavior is just by design, and your workaround of adding |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thank you for the reply. I will file an issue soon for the second problem I observed. Regarding the first issue, I am still not sure if I should enable EnableMsixTooling enabled
EnableMsixTooling disabled
|
BetaWas this translation helpful?Give feedback.
All reactions
-
Hm this isn't right, did you use the .NET 9 Windows App Packaging template to create the project or the old one? the old one won't work as-is |
BetaWas this translation helpful?Give feedback.
All reactions
-
I tried with a new app from the "Blank UWP App with Windows Application Packaging Project (Preview for .NET 9)" template and when I publish an msix file, the xbf files are not included. |
BetaWas this translation helpful?Give feedback.
All reactions
-
So with the release of RC2 does this process change? |
BetaWas this translation helpful?Give feedback.
All reactions
-
With RC2, you don't need to install a nightly build of the .NET SDK anymore. Also with VS 17.12 P3, you don't need to set "UseUwpTools" in the .csproj anymore, as it's automatic. And you don't need to specify "RuntimeIdentifiers" in libraries anymore. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
does this mean that UWP is comming back as GDKs account barriere makes it a bad option for xbox support and UWP was fine for that ? |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I am currently trying to upgrade a pretty large project to modern UWP. It’s a bit tedious because most referenced UWP packages can’t be used as they are and need to be adjusted locally. Right now, i use local builds amongst others of
So far i recognized several issues (in no particular order)
Overall, the preview does pretty good for what i was waiting for years ❤️. I am still far from getting my project running though. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I filedCsWinRT #1839. After recognizing that modern UWP defaults to |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1
-
The vs-threading package has this in the nuspec file: <frameworkReferences> <grouptargetFramework="net6.0" /> <grouptargetFramework="net6.0-windows7.0"> <frameworkReferencename="Microsoft.WindowsDesktop.App.WPF" /> </group> <grouptargetFramework=".NETFramework4.7.2" /> <grouptargetFramework=".NETStandard2.0" /> </frameworkReferences> The threading library has API that exposes WPF types, so on runtimes that support WPF, it necessarily references it. If the XAML compiler crashes when a project references a WPF assembly, that sounds like it's worth a distinct bug against the xaml compiler. |
BetaWas this translation helpful?Give feedback.
All reactions
-
That's expected, and the issue is that NuGet package is malformed. Even if it didn't crash the XAML compiler, bringing WPF references would still cause a ton of problems for NativeAOT. It's just incorrect to pull in UI framework dependent binaries based on TFM. The official recommendation is to have separate NuGet package per UI framework. Alternatively, you could have a .targets in the NuGet package that conditionally adds a reference to a WPF-specific .dll if some property is set. But unconditionally doing so like this is just a recipe for errors. For instance, System.Reactive also has the same issue, which makes it basically unusable with NativeAOT without hacks. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I'm curious whether such "incorrect" patterns are documented as such anyway. Regardless, it wasn't really a choice we had. vs-threading existed long before .NET did. And on .NET Framework, adding a WPF dependency was a non-issue. And as our WPF dependency is mixed into the same class as non-WPF dependencies in the library, we cannot simply move the class out into its own assembly. For binary compatibility then, we are required to have a WPF dependency in the threading library for |
BetaWas this translation helpful?Give feedback.
All reactions
-
The compiler issue seems to be fixed in VS 17.14 Preview 1 (I did not try 17.13 rtm) |
BetaWas this translation helpful?Give feedback.
All reactions
🎉 1
-
I want to come back to an issue that@lhak described above: content files of an UWP app are packaged at a different path in a separate wapproj. They moved into an |
BetaWas this translation helpful?Give feedback.
All reactions
-
I found the reason for the resource related issues: If there is a packaging project and
What is needed is a
APPX and MSIX files contain everything they need without any further |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thank you for looking into the issue! This matches what@dongle-the-gadget said, and it's on my todo list of things to do. This is going to potentially need more thought, because we're not going to be using WinAppSDK for the UWP support in the final release. At least for now, you have a workaround, so that's great. I'll try a few things out this week and see what a proper solution could be 🙂 |
BetaWas this translation helpful?Give feedback.
All reactions
-
Can you please point me to this? |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
I've followed migrations steps from the article, installed .NET SDK 9.0.200-preview.0.24527.8 and Windows SDK 10.0.26100.1742 and encountered a few issues that I hope you can help address:
|
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
|
BetaWas this translation helpful?Give feedback.
All reactions
👍 2❤️ 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@dongle-the-gadget@Sergio0694 Is there any solution to this? I was hoping to use Visual Studio Code to build my app. |
BetaWas this translation helpful?Give feedback.
All reactions
-
There are no plans to change that. Building UWP apps requires MSBuild Desktop, that's just by design. That said, youshould be able to also configure VS Code to build your project, as long as you make it use a VS Developer Command Prompt as the terminal used for building, and you make it use But if you wanted to be able to just have VS Code installed and not VS at all, then no that's never going to work 😅 |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Hi, I work for a company where we have created a line of business UWP app (not in the Store) over the last 7 years. Just the other day we were discussing the process for moving from UWP to an app developed with WindowsApp SDK, and all the issues that would entail. This new UWP for .Net 9 project has come at just the right time for us, as it will provide a more step by step approach to migration, allowing us to migrate firstly to .Net 9, then to WinUI3, and finally to the full Win32 model. I've installed VS2022 17.12 Preview 5 and all .Net Desktop and Windows App development components, the latest Windows 11 SDK version 10.0.26100.1742, and also the VSIX for the templates. On creating a new UWP for .Net 9 project, I'm getting the following error on build: Microsoft.UI.Xaml.Markup.winmd cannot be referenced. Referencing a Windows Metadata component directly when targeting .NET 5 or higher is not supported. For more information, seehttps://aka.ms/netsdk1130 This is literally from creation of a new project. No changes made at all. I've rebooted, double checked the installed VS2022 17.12 Preview components, all is as it should be. Can anyone help diagnose or help fix this issue? These are the dependencies that are added by default: I notice that under Packages, the SDK BuildTools are version 10.0.22621, is that correct? Is this the same version that everyone else has? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Did you follow the steps in the blog post to download and patch the XAML compiler? If not, that error is expected. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Edit: I've patched the XAML compiler. All working Ah no, as when I read the following in the blog postYou’ll also need an updated version of the XAML compiler that supports .NET 9 projects. This will be included in an upcoming servicing release of the Windows 11 SDK (10.0.26100.0) I assumed (wrongly I guess) that because I was installing Windows 11 SDK 10.0.26100.1742, a later version than specified, that it included the updated XAML compiler. Thx for getting back to me so quickly Sergio. I'm very happy that you've created this new toolset, as it will be a life saver for us, to be able to migrate our now approximately 7 years in development, UWP enterprise app. A pretty large app as well, as we had to move off of AppCenter for building as we "broke" the 4GB limit during compilation. Is the intention for developers with existing apps to be able to re-target / edit their existing projects in order to convert them into UWP for .Net 9 projects, or is the intention that in such use cases, a developer with an existing app, should ideally create a brand new blank UWP for .Net 9 project/solution, and migrate C# code and XAML over manually from the existing to the new project? Our project is very large, with a lot of projects/files. I'm hoping I can "convert" the existing projects, and then deal with the issues that arise, as to manually move everything over to a new project/solution whilst possible, will be a lot more involved. Either way, this is a great new feature that I'm excited exists!! |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1👀 1
-
Glad to hear this will be useful for you, that's great to hear! 🙂
You cannot multi-target existing projects, as the build infrastructure is completely different for .NET 9 projects. What I would personally recommend is to create a new project right next to the old one (ie. in the same folder). You can imagine something like:
That "MyApp2.csproj" file is a .csproj with the new UWP .NET 9 stuff. Because it's an SDK-style project, it will automatically import all files from its directory, meaning in VS you'll just see all files being shared with it like you would expect. This allows you to literally just create one project file to migrate an entire project, while fully sharing code. If you then need to do any specific changes to the code for modern .NET, you can easily do stuff like Hope this helps! |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1
-
Actually that's even better than I was hoping, as originally I was hoping to just go through and "convert" all existing projects in the solution with the new project structure, along with re-targetting to .Net 9, and the new SDK. Your proposed solution, and the one which you are using yourself on the Microsoft Store, having both old UWP .csproj files, and new UWP .Net 9 .csproj files side by side, with code sharing of the .cs files etc, is perfect, especially as I can also use conditional compilation as you mention, to handle cases where I need to do something different in the .Net 9 build Many Thx!! |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
First stumbling block, converting one of our class libraries, in our large UWP app, is that is uses the following nuGet package: Microsoft.UI.Xaml.Behaviors.Uwp.Managed However this cannot be installed in a UWP for .Net 9 class library, as it says it's not compatible with .Net 9. An alternative I could use is the following nuGet package: CommunityToolKit.UWP.Behaviors However, whilst that installs, it causes the following error: The type or namespace name 'Xaml' does not exist in the namespace 'Uno.UI' (are you missing an assembly reference?) as it seems that the package is dependent on the Uno.UI package, which is listed in the package manifest as a .net 8 dependency. Installing the Uni.UI nuget package manually, just results is many more errors :-( I guess this are the kinds of issues that are going to crop up as people migrate their UWP apps. It's not the fault of the nuGet package developers that they don't support .Net 9, nor that they for some reason have a dependency on the Uno.UI nuGet package, which is very incompatible with UWP for .Net 9 Other than stripping out functionality from our UWP app, that relies on XAML behaviors, I'm not sure how I can make this functionality work. |
BetaWas this translation helpful?Give feedback.
All reactions
-
This is expected, we haven't shipped the new versions of those packages yet. You'll be missing:
We're working on it, and we'll try to publish public previews/releases soon. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Again, thx for the quick reply. That's great the issue I'm encountering is expected, and it's great to know that these will be addressed as part of future planned work. I certainly didn't expect my first attempt to convert one if it libraries to 'just work'. This is a preview after all, and it's all about finding what works, what doesn't work etc. I'll try converting other libraries to see if I encounter any other issues, and raise anything relevant here. Many thx |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1
-
Now that .NET9 is released how should we start? Will theUpgrade Assistant be updated to include the new UWP project format? Or do we have to create a new project on our own and copy the files to the new project? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Now that VS 17.12 and .NET 9 are out in stable, that means you have access to the preview tooling for UWP without the need to install other components other than those two. You can manually add a reference toMicrosoft.Windows.SDK.CPP version |
BetaWas this translation helpful?Give feedback.
All reactions
👍 3
-
ok, so I'll wait a bit |
BetaWas this translation helpful?Give feedback.
All reactions
-
Have seen a dramatic improvement in all things related to UWP and WinUI since Sergio has been in the picture. Thank you! |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1❤️ 5
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Just tried to create a UWP project with .net 9 and the latest VS release. Microsoft.UI.Xaml.Markup.winmd cannot be referenced. Referencing a Windows Metadata component directly when targeting .NET 5 or higher is not supported. For more information, seehttps://aka.ms/netsdk1130 Which version of this should be used??
Is the nuget.config change still required? Never mind, I didn't realize I needed to leave the SDK version at the latest. Works! |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
You forgot to patch the XAML compiler. You also shouldn't be using WindowsAppSDK at all, that's for WinUI 3. I have the instructions for this in the blog post, with a link to the XAML compiler patch. Alternatively you can add a reference toMicrosoft.Windows.SDK.CPP version |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Got all this wrong. Picked the wrong starting template. Starting over. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Working steps with latest of everything are: Install Visual Studio 2022 version 17.12.0, install .Net 9 SDK, install UWP .Net 9 support VSIX, select this template select this target version add this to your project file
So you wind up with this:
|
BetaWas this translation helpful?Give feedback.
All reactions
👍 5
-
FYI you can remove:
|
BetaWas this translation helpful?Give feedback.
All reactions
👍 4
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@Sergio0694 , thank you very much. Was just describing a working, mostly out of the box, experience. Presumably, a new VSIX will clean some of this up in the short term. Hopefully, we'll see a UWP .Net 9 designer before too long. Yes, that includes a WinUI designer. I do appreciate the fact that things are looking much more professional again. The last WinUI community call looked pretty good. I opted out of all of this for almost two years because of where UWP/WinUI appeared to be headed. Nice work Sergio. Also really like what you contributed in your private repo. Perhaps some more updated bits could be added there. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Didn't have a chance to post this yesterday, so here's the cleaned corrected project file. Could we please have CsWinRTAotWarningLevel default to 2, or include it in the generated projects so we can bring it to 0 or 1 as needed.
When can we expect correct project generation (no extra junk) from VS 2022? Would be nice to open source the VSIX so the community can help itself as needed. It's not needed to open source things with sync expectations, some of us like to fork our variants for internal use, while you folks continue to do your thing. Lastly, I'm unclear about how XamlBehaviors will play along with AOT since it's been moved to a "managed" only build? Would be helpful to get some additional guidance around AOT considerations. Especially with options like AllowUnsafeBlocks. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Now that it's been over eight months since the last blog post about the preview .NET 9 support for UWP, I assume we no longer need to install anything special, as long as we have the latest version of VS, the appropriate workloads, and create a new project using the right template? Should we be using the templates that now ship with VS with names such as "UWP Blank App", etc. (those that do NOT include ".NET Native")? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Correct, everything is in GA now and fully supported. Just install VS and use the built-in templates and you're good to go 🙂 |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1
-
We have a UWP HoloLens 2 application that doesn't use any XAML (UI is created with DirectX). I'm attempting to migrate it to .NET 9 using the techniques described above. I've started by adding a new project to the existing folder using the "UWP Blank CoreApplication App" template and now I'm working through the problems one-by-one. So far, so good! |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
That's awesome! Really happy that new template is being useful 😄
Your app is a .NET 9 app, which also uses the UWP app model, and the UWP XAML framework for its UI. It's all of those things 🙂
It depends what you're talking about:
Those docs only say that those APIs won't work in traditional Desktop apps (as in, Win32 apps). They work fine on UWP. |
BetaWas this translation helpful?Give feedback.
All reactions
-
That helps - thank you!
Ok, I must be misunderstanding something - I'll dig in some more |
BetaWas this translation helpful?Give feedback.
All reactions
-
Ah, some static "GetForCurrentView" calls (such as SpatialInteractionManager.GetForCurrentView) were returning 0x80070490 (Element Not Found). Looking around the web, that lead me tothis page. But, as you pointed out, that doesn't really apply here. Digging deeper, that error can also mean there's no CoreWindow assigned to the current thread. Now I realize that some of my migrated code is running on different threads than it did under the "old UWP" because now there's no SynchronizationContext early in the IFrameworkView lifetime, where there was before. |
BetaWas this translation helpful?Give feedback.
All reactions
-
You'll need to manually register it, yeah. You can copy the code for it that the XAML compiler is creating in a UWP XAML app 🙂 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Hi 👋 I have done some tests with the new .NET 9 support for UWP and all seems to be working nicely except the background tasks. I have test a lot of things based on available peace of documentation here and here without success. I have create a very small test project. Someone has succeed to use one background task with the new tooling? There is some guidance somewhere ? I see the Microsoft Store app (preview) is using a lot of tasks and has been migrated to .NET 9, so I think I miss something. Thank you for your help. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Your setup seems right, I think you're just missing this option in your app .csproj: <CsWinRTMergeReferencedActivationFactories>true</CsWinRTMergeReferencedActivationFactories> You'll also need CsWinRT 2.3 (as it has some additional support needed for this), but we haven't release it yet. So basically until then, background tasks can't work, but you're not doing anything wrong. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Thank you Sergio! Have you an idea for the release timeframe of CsWinRT 2.3 ? Possibility of a preview ? |
BetaWas this translation helpful?Give feedback.
All reactions
-
I'd like to release it sometime in May, for sure at least a preview. I'll see if we can get something out soon-ish 🙂 |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 3
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@Sergio0694 Any news on the CsWinRT 2.3 Preview or GA release ? I expected some news around MS Build but I see nothing (or I missed). Even a preview will allows us to continue to work on the subject 🙂 |
BetaWas this translation helpful?Give feedback.
All reactions
-
We're trying to get a preview build out next week, if things line up 🙂 |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 2
-
I've converted our old UWP (HoloLens) app to .NET 9 (UWP) using the latest tools and the tips in this discussion. I did it by creating a new project in the same folder using the "UWP Blank CoreApplication App" template and then tweaking a few things related to COM/WinRT interop. We can deploy it to the HoloLens and run and debug it. This is awesome - thank you! We've been sideloading our old UWP app from a website for months. Our yaml pipeline (in Azure DevOps) runs the following command:
(we sign it later) Now, this command succeeds but there is no MSIX, etc. output to the "C:\agent2_work\8\a\Packages\HoloImmersiveNet" folder like there used to be. I'm assuming this has something to do with how projects and targets have changed since good ol' UWP, but I'm not sure what. I apologize for my ignorance. Is it expected that I'd need to change something MSIX/AppX related after converting my UWP project to .NET 9? Note: there was a warning in the pipeline build log, but I'm assuming it's not related to MSIX packaging...
|
BetaWas this translation helpful?Give feedback.
All reactions
-
You need to set
That package needs to be updated to stop using |
BetaWas this translation helpful?Give feedback.
All reactions
❤️ 1
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Thank you! I updated the msbuild call to include /p:GenerateAppxPackageOnBuild, but that caused this error:
Digging through the build log, we noticed setting UseUwp=true causes UseUwpTools to become true, which we assume triggers the "pack" target in some of our projects, which we don't want in this case. Setting UseUwpTools explicitly to false in the csproj fixes the circular dependency error and the MSIX generates successfully. Here's the project hierarchy... Setting UseUwpTools to false in the Library project fixes the target circular dependency. Is this expected or are we doing something wrong? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Yes, that's why I said to only enable itin the app project that should produce the MSIX file 😄 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Ah! ok, thank you for the clarification. I'm sorry I missed that detail. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Will .net 10 have any improvements for uwp support ? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Not sure what you mean, do you have any examples of things you're like to be improved? UWP will get .NET 10 support etc. like any other UI framework as well, so all those improvements will just be there automatically. There isn't anything specific for UWP there. |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@Sergio0694 Thank you for the good work. We are planning to upgrade a big UWP app to .net 9. It has background services, we are not sure how they will be affected. Secondly, the project is layered (mvvm) with .net standard, should update this .net standard targeting to .net 9 ? |
BetaWas this translation helpful?Give feedback.
All reactions
-
That's supported, but you'll need to wait for CsWinRT 2.3 to get those to work (you needthis andthis).
Yes, that's recommended to make things AOT-safe. You might actually want to target |
BetaWas this translation helpful?Give feedback.
All reactions
-
@Sergio0694, are you able to weigh in on this topic of maybe reinstating support for UWP?https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/ 5144 Based on one of the response from austinbhale, maybe allowing it to work with UWP is not too difficult? I attempted to build what he linked, but I wasn't successful. I think MSAL is the only blocker for my conversion. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I was finally able to build the changes by austinbhale. I ran into "value does not fall within expected range" exceptions and had to put in |
BetaWas this translation helpful?Give feedback.
All reactions
-
When is the CsWinRT 2.3 GA Date ? …On Tue, 6 May 2025, 09:23 Sergio Pedri, ***@***.***> wrote: "It has background services, we are not sure how they will be affected." That's supported, but you'll need to wait for CsWinRT 2.3 to get those to work (you need this <microsoft/CsWinRT#1637> and this <microsoft/CsWinRT#1895>). "should update this .net standard targeting to .net 9 ?" Yes, that's recommended to make things AOT-safe. You might actually want to target net9.0-windows10.0.XXXX.0 directly. — Reply to this email directly, view it on GitHub <#9983 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABCE7FRYUKOIFO2CDBMG63L25BIMNAVCNFSM6AAAAABOEIYBJWVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMBUGY3TSMA> . You are receiving this because you commented.Message ID: <microsoft/microsoft-ui-xaml/repo-discussions/9983/comments/13046790@ github.com> |
BetaWas this translation helpful?Give feedback.
All reactions
-
@Sergio0694 Thanks for all your great job regarding UWP+NET9 support! I'm currently migrating a large app and i'm facing an issue in RELEASE mode: app works fine in DEBUG but in RELEASE mode all XAML binding raise exception:
App use regular MVVM pattern and exception is raised for every viewmodels property access. Adding this undocumented GeneratedBindableCustomProperty attribute seems to solve issue but it's quite strange that I need to add it everywhere. Am I missing something? |
BetaWas this translation helpful?Give feedback.
All reactions
-
Are you using |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
@MartinRichards23 thanks for quick reply! I'm mostly using x:bind and a few Binding. I commented Binding but still facing issue. |
BetaWas this translation helpful?Give feedback.
All reactions
-
@MartinRichards23 You're right, issue is directly related to {Binding}. Thanks! |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
@Sergio0694 &@duncanmacmichael: I have a quick question before I dive down the rabbit hole - does UWP on .NET 9 work with the 'Kiosk Mode' functionality in Windows, specifically the single-app kiosk using Assigned Access? UWP has a nifty and super-secure approach to displaying UI above the lock-screen for kiosk apps using the My concern is that this might be wrapped-up in .NET Native and WinUI 2, so before I go ahead and burn a bunch of time diving into this I figured I'd ask here. Otherwise, we're in a position where we'd be building a brand-new UWP app on .NET Native, with polyfils for our modern .NET dependencies, which I'd like to avoid if we can use modern .NET. Some links for reference:
|
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Yes it'll work. It doesn't care what runtime you use as long as it's UWP. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 3
-
Great, thanks! Just to be clear, it's happy to render WinUI 3 in this way and doesn't rely on platform hooks in WinUI 2 to achieve the dual view stuff? If so, I'm a very happy chappy! |
BetaWas this translation helpful?Give feedback.
All reactions
-
UWP .NET 9 uses WinUI 2 though, not 3 |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Ah, cool - misunderstood that bit. Can you tell I haven't gone into detail on this yet? 😅 Thanks for the help - will do a deep dive on this next since it sounds viable. |
BetaWas this translation helpful?Give feedback.
All reactions
-
I wan't migrate UWP app with some out of support libraries(like MVVMLight), third party libraries target to .NET Standard 2.1 or libraries target to UAP 10.0.17763. Could there be any problems with third party libraries not being built with .NET 9 support? |
BetaWas this translation helpful?Give feedback.
All reactions
-
UAP libraries won't work. NS2.1 shouldn't be a problem though unless it's not AOT compatible. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Also note that MVVMLight is deprecated, and the recommendation is to use theMicrosoft MVVM Toolkit 🙂 |
BetaWas this translation helpful?Give feedback.
All reactions
-
@dongle-the-gadget thanks! I read the discussion and saw that some people have problems with |
BetaWas this translation helpful?Give feedback.
All reactions
-
I reproduced a basic but very annoying issue with ItemsControl/ItemsRepeater: if you try to set ItemsSource with non basic IEnumerable, a "value does not fall within expected range" exception occured when PublishAot is activated. I'm using 9.0.300-preview.0.25177.5 SDK (latest VS Preview)
|
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Binding to IList<> also results in the error "Value does not fall within the expected range." ListView.ItemsSource = Items.... For example:
|
BetaWas this translation helpful?Give feedback.
All reactions
-
Do you have |
BetaWas this translation helpful?Give feedback.
All reactions
-
Yes, I have. <AllowUnsafeBlocks>true</AllowUnsafeBlocks> Now I see that the issue occurs when the model is in a separate .NET9 library. I tried adding <AllowUnsafeBlocks>true</AllowUnsafeBlocks> to the library's .csproj file, but it had no effect. |
BetaWas this translation helpful?Give feedback.
All reactions
-
What TFM is that library being built for? Is it just |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
This is a library .csproj <Project Sdk="Microsoft.NET.Sdk"> When I set PublishAot=false in the main UWP project, the application works. |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hello 😀, I'm developing a UWP application using .NET 9 with NativeAOT. When I try to publish the project, I get the following error:
I do not explicitly reference System.Private.CoreLib.dll in my project. However, I noticed that my project implicitly references: Microsoft.DotNet.ILCompiler version 9.0.4 Microsoft.NET.ILLink.Tasks version 9.0.5 Both are SDK-implicit references, and NuGet UI says their versions are determined by the SDK and cannot be changed manually. Could the error above be caused by these two implicitly referenced packages, since their versions (9.0.4 and 9.0.5) exactly match the versions mentioned in the error message? If so, how can I resolve this issue? Any help would be greatly appreciated! For reference, the full project source code is availablehere |
BetaWas this translation helpful?Give feedback.
All reactions
-
Does clearing the NuGet cache and restarting Visual Studio helps? |
BetaWas this translation helpful?Give feedback.
All reactions
👍 1
-
Thank you so much for your suggestion! Clearing the NuGet cache and restarting Visual Studio actually solved the problem. I can't believe I forgot to try that earlier. Really appreciate your help! |
BetaWas this translation helpful?Give feedback.
All reactions
-
Hi all! First, let me thank all the passionate devs responsible for bringing modern .NET to UWP! I've been able to successfully migrate my app to .NET 9. It was not an easy task, and I've hit a few bumps here and there, but in the end I think it was worth it :). I've been able to generate MSIX files for x86/x64/ARM64, and use MakeAppx to create a bundle, but I'm not able to let Visual Studio create the bundle for me. When I try, I get the following error: I'm wondering if this issue is specific to ARM64 VS (I'm coding on a Snapdragon X Surface Pro), or if it's something I did wrong during the migration process. Thanks! |
BetaWas this translation helpful?Give feedback.
All reactions
-
Are you on VS 17.14? Can you also try this (in your .csproj): <MicrosoftWindowsSDKBuildToolsMSIXPackageVersion>1.7.20250508.1</MicrosoftWindowsSDKBuildToolsMSIXPackageVersion> |
BetaWas this translation helpful?Give feedback.
All reactions
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
-
Thanks for the quick reply. |
BetaWas this translation helpful?Give feedback.
All reactions
-
BetaWas this translation helpful?Give feedback.
All reactions
-
You should reference CsWinRT and add this to your csproj: <CsWinRTIncludes>Microsoft.Services.Store.Engagement</CsWinRTIncludes> |
BetaWas this translation helpful?Give feedback.
All reactions
👍 2
-
Thank you that works perfectly |
BetaWas this translation helpful?Give feedback.