Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
We recommend using the Visual Studio .NET Upgrade Assistant to update .NET Framework code to the latest .NET versions. For more information see the blog Upgrading your .NET projects with Visual Studio.
Important
API Port has been deprecated in favor of binary analysis with the .NET Upgrade Assistant tool. The backend service of API Port has been shut down, so to use the tool, you must use it offline. For more information, see .NET API Port README.
Before you jump straight into the code, take the time to go through the recommended pre-migration steps. This article gives you insight into the kinds of issues you may come across, and helps you decide on an approach that makes the most sense.
Make sure that you follow the prerequisites to porting code before you continue any further. Be ready to decide on the best approach for you and begin porting code.
This approach works well for small projects or projects that don't use many .NET Framework APIs. The approach is simple:
Although it's unstructured, this code-focused approach often resolves issues quickly. A project that contains only data models might be an ideal candidate for this approach.
This approach might be the best if you prefer to have code that compiles during the entire process. The approach is as follows:
This careful approach is more structured than simply working out compiler errors, but it's still relatively code-focused and has the benefit of always having code that compiles. The way you resolve certain issues that couldn't be addressed by just using another API varies greatly. You may find that you need to develop a more comprehensive plan for certain projects, which is covered in the next approach.
This approach might be best for larger and more complex projects, where restructuring code or completely rewriting certain areas of code might be necessary to support .NET. The approach is as follows:
Run ApiPort on a project.
Understand where each non-portable type is used and how that affects overall portability.
If you have assemblies that are difficult to port, is it worth leaving them on .NET Framework for now? Here are some things to consider:
Is it reasonable to write your own implementation of an unavailable .NET Framework API?
You could consider copying, modifying, and using code from the .NET Framework reference source. The reference source code is licensed under the MIT License, so you have significant freedom to use the source as a basis for your own code. Just be sure to properly attribute Microsoft in your code.
Repeat this process as needed for different projects.
The analysis phase could take some time depending on the size of your codebase. Spending time in this phase to thoroughly understand the scope of changes needed and to develop a plan usually saves you time in the end, particularly if you have a complex codebase.
Your plan could involve making significant changes to your codebase while still targeting .NET Framework 4.7.2. This is a more structured version of the previous approach. How you go about executing your plan is dependent on your codebase.
It's likely that you'll mix the above approaches on a per-project basis. Do what makes the most sense to you and for your codebase.
The best way to make sure everything works when you've ported your code is to test your code as you port it to .NET. To do this, you'll need to use a testing framework that builds and runs tests for .NET. Currently, you have three options:
Ultimately, the porting effort depends heavily on how your .NET Framework code is structured. A good way to port your code is to begin with the base of your library, which is the foundational components of your code. This might be data models or some other foundational classes and methods that everything else uses directly or indirectly.
If you start with the base of your library and move outward from the base and test each layer as needed, porting is a systematic process where problems are isolated to one layer of code at a time.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Modernize ASP.NET Framework to ASP.NET Core with the .NET Upgrade Assistant - Training
In this module, you'll learn to when, why, and how to modernize an ASP.NET Framework app to ASP.NET Core using the Upgrade Assistant.
Certification
Microsoft Certified: Power Platform Developer Associate - Certifications
Demonstrate how to simplify, automate, and transform business tasks and processes using Microsoft Power Platform Developer.