Back to writing

Architecture

Modernizing Legacy Systems Without Rewriting Everything

How I moved a business-critical desktop app from .NET Framework 4.7.1 to .NET 8 in stages, without a rewrite and without changing how people used it.

· 4 min read

  • Modernization
  • .NET
  • Risk

I led the move of a business-critical desktop application from .NET Framework 4.7.1 to .NET 8. We didn't rewrite it. We moved it in stages, and the people who depend on it kept working the whole time.

Why not rewrite

An app people have relied on for years has rules in it that nobody wrote down. An odd branch might be a bug, or it might be something a customer depends on, and the code alone often can't tell you which.

A rewrite loses all of that, and you find the rules again one bug report at a time. Upgrading in place keeps the running app as the reference. If the new version behaves differently, the difference gets explained before it ships.

Dependencies first

Most of the cost was in the packages. Before changing the target framework, I went through the dependencies and put each one in a group:

  • upgrade it directly
  • replace it with something supported
  • remove it, because nothing needs it anymore
  • isolate it for now, because it can't move yet

That list became the plan. It was also a better way to report progress than a percentage: these risks are gone, and these are left.

One kind of change per stage

If one step changes the runtime, swaps libraries, restructures the code and renames things, every bug has four possible causes. So each stage changed one kind of thing.

Moving the runtime didn't come with a redesign. Some awkward code went over to .NET 8 exactly as it was. Cleaning it up later, on a supported runtime, was a small normal change instead of part of a huge one.

Encryption

Some of the old code wasn't only ugly, it was unsafe on a modern stack. In this app that was encryption code built on APIs that are now obsolete.

I replaced it with current APIs as its own piece of work, with the old and new behavior written down and tests aimed at exactly that path. Anything already encrypted the old way still had to be readable by the new code.

Checks for each stage

A stage wasn't done when it compiled. Each one ended with the main workflows tested before it went out more widely:

  • it builds and starts on the new runtime
  • the main workflows behave the same as before
  • data reads and writes the same way
  • the security-sensitive paths still work
  • we know how to deploy it and how to roll it back

Parts that couldn't move

When a component couldn't move forward cleanly, I isolated it behind a boundary or replaced it, so it didn't hold up the rest of the app.

The app now runs on .NET 8 with supported dependencies and current encryption. The team no longer has to work around the old stack, and the people using it didn't have to change how they work.