Migrate WPF Applications to .NET
- 3 minutes to read
This topic describes how to upgrade a WPF application that uses DevExpress controls to .NET. Once you switch the target platform, you can leverage the new framework’s advanced capabilities.
Before You Start
Prerequisites
- .NET
- Visual Studio 2022 v17.0+ with .NET desktop development workload installed
Migrate an Application
The DevExpress Unified Component Installer ships with the .NET Core Migration Tool.
Select the project you want to convert in the Solution Explorer and select Migrate the Current .NET Framework Project to .NET in the Visual Studio’s DevExpress menu:
The .NET Core Migration Tool uses the .NET try-convert tool to convert your project to the SDK-style format and replaces DevExpress assembly references with NuGet package references. Select the desired .NET version and click Convert.
After the conversion completes, the .NET Core Migration Tool displays the output of the try-convert tool. Click Finish to close the tool and reload the project when prompted.
Note
You need .NET 5.0 SDK installed to run this converter tool.
Note
Library type projects converted by the .NET Core Migration Tool target netstandard2.0
.
Consider Portability Limitations
.NET misses a part of APIs that are present in the .NET Framework. Use the .NET Portability Analyzer tool to determine whether your application uses such APIs.
Try to refactor your code to reduce the number of calls to missing APIs. Look for an alternative API with the required functionality.
Useful resource: .NET Framework technologies unavailable on .NET.
Update Non-DevExpress NuGet Packages
DevExpress NuGet packages are compatible with both .NET and .NET Framework platforms.
Check whether the non-DevExpress NuGet packages used within your project are compatible with .NET and whether newer compatible versions are available.
Update your project to reference the latest package versions, if necessary.
Tip
Perform this step even if Visual Studio does not show any compile-time errors. You may experience runtime exceptions if you build the application with packages that were not tested against .NET runtime.
Fix Build Issues
If Visual Studio shows build errors, follow the output to refactor your code until you can successfully compile it.
Tip
Use the Microsoft.Windows.Compatibility package to access Windows-specific APIs: Registry, WCF Client, ACL, etc.
Use conditional compilation to write small parts of code that are different for the .NET and .NET Framework.
Known Limitations
Visual Basic projects display the following warning after conversion:
.vbproj uses code generators which will not be handled by try-convert. You can edit your vbproj to add support or remove these dependencies.
The default .NET platform is AnyCPU. If your .NET Framework solution has only the x86 platform configured, manually specify the platform in the project file:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <Platforms>x86;AnyCPU</Platforms> ... </PropertyGroup> ... </Project>
Test Your App
Run and test the upgraded app. Remember that runtime exceptions are possible even if the application was built without compile-time errors.
Useful Resources
The following Microsoft topic gives an overview of useful techniques and automated tools to port your code to .NET: Port your code from .NET Framework to .NET.