Mocking MessageBox (or any static class) in WinForms

Unit testing a WinForms app is an uphill battle in the best of times, before you add in classes like MessageBox. Let’s make the best of it.

  Jan 7, 2022 (rev. Sep 16, 2025) ·  4 min

Using nameof to avoid magic strings in C#

There’s a lot of ways to make our code work for us. Let’s check out using the nameof operator to avoid magic strings.

  Dec 30, 2021 (rev. Sep 16, 2025) ·  6 min

A more helpful exception box for WinForms apps

If you’re in a legacy codebase with a centralized “message box” form, why not add some features that make it work for you? 😏

  Dec 7, 2021 (rev. Sep 16, 2025) ·  3 min

How to log errors in WinForms using NLog

Logs are a great tool for squashing bugs and tracing errors. Let’s see how to add NLog to our project.

  Oct 9, 2021 (rev. Sep 16, 2025) ·  5 min

Using MVP to test a WinForms app

If you find yourself supporting a WinForms application, you’re likely to notice the tests… or lack thereof. Just because we may not have been so focused on automated tests and continuous integration when WinForms was younger, that doesn’t mean we can’t introduce them now. Better late than never!

  Jun 9, 2021 (rev. Sep 16, 2025) ·  9 min

Using Async, Await, and Task to keep the WinForms UI responsive

Using the async/await pattern in WinForms is an easy win, helping prevent one of the most annoying user experiences - a frozen UI.

  Jun 7, 2021 (rev. Sep 16, 2025) ·  8 min