Skip to content
Tutorials Center
My learning

Topics

Lesson 33 of 36 ยท Interop and Migration

Migrating to Modern .NET

Plan a VB.NET migration from .NET Framework 4.x to modern .NET - SDK-style projects, the upgrade assistant, compatibility analysis, My namespace, WinForms support, strangler pattern, tests and what VB cannot do.

Millions of lines of VB.NET still run on .NET Framework 4.x, the Windows-only runtime that ships inside Windows. Microsoft keeps patching it, but new runtime features, performance work and cross-platform support land only in modern .NET (the unified platform that began with .NET 5 and continues with .NET 8 LTS, 9 and 10). This lesson explains what migration means for a VB application, what changes, what stays, and how to do it safely.

No VB compiler or migration tooling exists on this site. Project files and commands here are read-only reference. The runnable blocks are C# stand-ins for ideas such as API compatibility checks and the strangler approach.

Why migrate?

  • Performance and memory: modern .NET is much faster than Framework in common workloads.
  • Support: each LTS release has a defined support window; .NET Framework is in maintenance only.
  • Tooling: SDK-style projects, dotnet CLI, simple builds, containers, trimming.
  • Libraries: new packages increasingly target only modern .NET (or netstandard2.0 at best).

You do not have to migrate if the app is stable, Windows-only and rarely changed. Migrate when you need new libraries, performance, containers, or a long support horizon.

What stays and what changes

Area Status in modern .NET
VB language itself Supported (VB 16.9 level; no major new features)
Windows Forms, WPF Supported, Windows only
ASP.NET Web Forms, WCF server, Remoting Not available (alternatives exist)
My namespace Available (slightly reduced in some project types)
System.Data.SqlClient Replace with Microsoft.Data.SqlClient
app.config / ConfigurationManager Works; new code prefers appsettings.json
GAC, AppDomains No GAC; one AppDomain only
Visual Studio designer Works for WinForms on modern .NET (out-of-process designer)

Note the VB limitation: the VB compiler runs on modern .NET, but templates for ASP.NET Core projects are not offered for VB, and the language team has stated that VB is on a stability track. A common outcome is "keep the VB desktop app, write new web services in C#".

SDK-style project files

Old Framework .vbproj files list every file and are hundreds of lines long. SDK-style projects are tiny and include files by convention:

XML
<!-- Before: .NET Framework (abbreviated) -->
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup><TargetFrameworkVersion>v4.8</TargetFrameworkVersion> ... </PropertyGroup>
  <ItemGroup><Compile Include="Form1.vb" /> <Compile Include="Form1.Designer.vb" /> ... </ItemGroup>
</Project>

<!-- After: modern .NET -->
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net8.0-windows</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
    <RootNamespace>MyApp</RootNamespace>
    <MyType>WindowsForms</MyType>
    <OptionStrict>On</OptionStrict>
  </PropertyGroup>
</Project>

MyType keeps the My namespace and application framework alive. NuGet references move from packages.config to PackageReference items in the project file.

A step-by-step plan

flowchart TD
    A["1. Inventory: projects, packages, APIs"] --> B["2. Add tests around key behavior"]
    B --> C["3. Upgrade packages and move to PackageReference"]
    C --> D["4. Run .NET Upgrade Assistant / API analyzer"]
    D --> E["5. Convert library projects first (netstandard2.0 or net8.0)"]
    E --> F["6. Convert the app, fix compile errors"]
    F --> G["7. Test, ship, then remove old code"]

Libraries go first so the app can reference them from either runtime during the transition.

  1. Inventory. List projects, target frameworks, third-party packages (do they have modern versions?) and APIs that no longer exist (Web Forms, WCF server, Remoting, System.Web).
  2. Tests first. A migration without tests is a guess. Characterization tests that lock in current behavior pay for themselves.
  3. Analyze. Microsoft's .NET Upgrade Assistant and the API Portability Analyzer report incompatible APIs. Install via the CLI (dotnet tool install -g upgrade-assistant) and run upgrade-assistant analyze or use the Visual Studio extension. (Reference only: not runnable here.)
  4. Libraries first. Retarget class libraries to netstandard2.0 (usable by both runtimes) or directly to net8.0.
  5. The app. Convert the project file, fix compile errors (mostly package swaps and removed APIs), then fix run-time differences (culture, encoding defaults, Process.Start needing UseShellExecute, BinaryFormatter removal).
  6. Verify and ship. Compare outputs, performance and memory on realistic data.

Run-time differences that surprise people

  • BinaryFormatter is removed for security reasons; use System.Text.Json or another serializer.
  • Encodings: only a few encodings come built-in; to use code pages such as Windows-1252 register CodePagesEncodingProvider.
  • Globalization: modern .NET on Linux uses ICU, which can change sorting and formatting slightly.
  • Configuration: ConfigurationManager.AppSettings still works with app.config but you should consider appsettings.json.
  • High-DPI: Windows Forms on .NET changed default DPI handling; set ApplicationHighDpiMode in the project or Application.SetHighDpiMode.
C# A compatibility report (C# stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with Console.ReadLine()), it gets the next line from this box.

The strangler approach for big applications

When a full conversion is too risky, grow the new beside the old: keep the Framework application running, move one feature at a time into a modern .NET library or service, and route calls to it until nothing is left in the old code. A small HTTP service in front of a feature gives VB and C# code a clean, language-neutral boundary.

C# Routing between old and new implementations

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with Console.ReadLine()), it gets the next line from this box.

Should new code be VB at all?

If you maintain a VB codebase, keep writing VB there; it is fully supported and mixing languages inside one feature costs more than it saves. If you are starting a web service, a library for a wide audience, or a project that needs the latest language features, C# is the pragmatic choice, and the comparison lesson shows that the skills transfer almost entirely.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which technology is NOT available in modern .NET?

    Web Forms (System.Web) is Framework-only; WinForms is supported on Windows.
  2. 2. Why migrate class libraries first?

    Libraries can be shared during the transition while the app is converted later.
  3. 3. What replaces System.Data.SqlClient in new code?

    Microsoft.Data.SqlClient is the actively developed provider.
  4. 4. What is the strangler approach?

    New code gradually takes over features from the old system.

Summary

  • Modern .NET is the future platform; VB and Windows Forms are supported, Web Forms and WCF server are not.
  • SDK-style project files, PackageReference and net8.0-windows replace the old format.
  • Plan: inventory, tests, analyzer, libraries first, then the app, then verify.
  • Watch for run-time differences (BinaryFormatter, encodings, DPI, globalization).
  • Use the strangler pattern for large systems.

Next: Project: Expense Tracker Design