Are you developing .NET applications for Arm-based processors? Do you want to take advantage of the performance and power efficiency of running your apps natively on Arm64 devices? If so, you’ll be happy to hear that Visual Studio 2022 17.11 has a new feature that makes it easier than ever to do just that.
Visual Studio 2022 natively supports building and debugging Arm64 apps on Arm-based processors. However, if you build your app with the AnyCPU setting, which is the default for most .NET projects, your app will run on an Arm64 device using x64 emulation. While this may seem counterintuitive, this approach allowed many apps with x64 dependencies to work reliably under emulation without requiring additional build or dependency changes.
Unfortunately, under these conditions, it means your app won’t benefit from the native capabilities of the Arm64 CPU and may suffer from reduced performance and increased battery consumption.
To solve this problem, the Windows 24H2 update introduces a new setting for your app manifest files. This setting allows you to specify a list of supported architectures (currently amd64 or arm64) for your app, indicating that it should run natively on those platforms. For example, if you include arm64 in the list, your app will run using the Arm64 CLR on Arm64 devices when supported, even if it was built with the AnyCPU setting.
How to use the setting in Visual Studio 2022
To use the new setting in Visual Studio 2022, you need to do the following steps:
- Make sure you have the Windows 24H2 update installed on your development machine and your target device.
- Open your .NET project in Visual Studio 2022 and right-click on your project in Solution Explorer and select Properties.
- In the Build area confirm that the AnyCPU configuration is enabled and that the Prefer 32-bit option is unselected.
- Select the new Prefer native ARM64 option.
- Save and rebuild your project.
- Deploy your app to your Arm64 device and run it. You can also debug it using Visual Studio 2022, which will automatically detect the correct architecture and launch the debugger accordingly.
Enjoy the benefits of native Arm64 apps
By using the new setting in Visual Studio 2022, you can easily run and debug your .NET apps natively on Arm64 devices, without changing your code or your build configuration. This will help you improve the performance, reliability, and battery life of your apps, and give your users a better experience.
We hope you enjoy this new feature and find it useful for your development scenarios. As always, we appreciate your> feedback and suggestions, which help us make Visual Studio better for you. Please let us know what you think by leaving a comment below, or by using the Report a Problem tool in Visual Studio. Thank you for choosing Visual Studio 2022!