News

Q&A with Rockford Lhotka: Migrating C# Code from .NET Framework to .NET Standard

Microsoft's game-changing .NET Core initiative that's superseding the Windows-only .NET Framework will this year reach an important milestone, .NET 5, a unification of all things .NET. Key to this cross-platform transition is .NET Standard, which specifies APIs common across all .NET implementations, created to allow libraries to build against an agreed-on set of common APIs so they work in mobile, desktop, IoT, web, or any other .NET applications.

With .NET 5 coming in November, we caught up with expert .NET developer, author and frequent speaker Rockford Lhotka to get his take on migrating to the new way. He's the man for the job, as he will be at the upcoming Visual Studio Live! conference in Austin running from March 30 to April 3 for a presentation titled "Migrate Your C# Code from .NET Framework to .NET Standard."

What are some of the top issues that development teams need to consider when moving from .NET Framework to .NET Standard/.NET Core?
The first step is to ensure your existing .NET Framework code and apps are running .NET Framework 4.7.2 or higher -- that's basically the core requirement to a smooth migration going forward.

The second step is to evaluate each of your apps. Are the apps well-architected so there's no business or data access code in the UI? If so life is pretty good, but if not then you need to (a) update as-is and lose out on modern benefits; (b) update to a good architecture, then move forward; (c) rewrite the app from scratch.

What are the top pain points people usually run into when transitioning?
So much depends on how well-architected your current code is relative to separation of data, business, and UI logic. If your code has good separation the pain is that of learning new and exciting things to take advantage of.

"If your code has good separation the pain is that of learning new and exciting things to take advantage of. If your code has poor separation, then getting good separation is the pain point."

Rockford Lhotka, CTO, Magenic

If your code has poor separation, then getting good separation is the pain point.

What's your #1 top tip for making the process go smoother?
Get to .NET Framework 4.7.2, move your non-UI code to a .NET Standard project, then work on your new .NET Core UI.

.NET Core or .NET Standard?
.NET Core is the current runtime for .NET, especially ASP.NET Core, but also the latest Windows Forms and WPF. Contrast this to .NET Standard, which allows you to create common DLLs that contain data access or business logic so those DLLs can be used by .NET Framework and .NET Core (and Xamarin and Blazor) apps.

Is it absolutely necessary to move now? If people don't move, what benefits are they missing out on?
It is not necessary to move now, but it is necessary to have a plan to move. Microsoft has said .NET Framework 4.8 is the last version of the framework. All new features and capabilities are going into .NET Core (really into .NET 5, which is the evolution of .NET Core). The longer you wait to become current, the more technical debt you will accumulate, and the harder it will be to find developers willing to work on legacy technology.

Any "Gotchas" with the process you want to pre-warn readers about?
There are different ways to move your data and business code to .NET Standard. Direct upgrade, multi-targeting projects, and using shared projects. Each has good and bad points, and it is important to understand the tradeoffs before starting the modernization process.

About the Author

Becky Nagel serves as vice president of AI for 1105 Media specializing in developing media, events and training for companies around AI and generative AI technology. She also regularly writes and reports on AI news, and is the founding editor of PureAI.com. She's the author of "ChatGPT Prompt 101 Guide for Business Users" and other popular AI resources with a real-world business perspective. She regularly speaks, writes and develops content around AI, generative AI and other business tech. Find her on X/Twitter @beckynagel.

comments powered by Disqus

Featured

  • Compare New GitHub Copilot Free Plan for Visual Studio/VS Code to Paid Plans

    The free plan restricts the number of completions, chat requests and access to AI models, being suitable for occasional users and small projects.

  • Diving Deep into .NET MAUI

    Ever since someone figured out that fiddling bits results in source code, developers have sought one codebase for all types of apps on all platforms, with Microsoft's latest attempt to further that effort being .NET MAUI.

  • Copilot AI Boosts Abound in New VS Code v1.96

    Microsoft improved on its new "Copilot Edit" functionality in the latest release of Visual Studio Code, v1.96, its open-source based code editor that has become the most popular in the world according to many surveys.

  • AdaBoost Regression Using C#

    Dr. James McCaffrey from Microsoft Research presents a complete end-to-end demonstration of the AdaBoost.R2 algorithm for regression problems (where the goal is to predict a single numeric value). The implementation follows the original source research paper closely, so you can use it as a guide for customization for specific scenarios.

  • Versioning and Documenting ASP.NET Core Services

    Building an API with ASP.NET Core is only half the job. If your API is going to live more than one release cycle, you're going to need to version it. If you have other people building clients for it, you're going to need to document it.

Subscribe on YouTube