Skip to main content

Using the .NET Upgrade Assistant to upgrade a Windows Forms App–Part II

Yesterday I demonstrated how we could use the .NET Upgrade Assistant to help us port a 10 year old WinForms application to .NET Core. We tried the 'analyze' mode to do a dry-run of the upgrade process.

Today I continue with a follow-up post where we have a look at the warnings and diagnostic messages I got and see how we can get rid of them.

Warning - HighDpiMode

We’ll start easy with the following warning:

HighDpiMode needs to set in Main() instead of app.config or app.manifest - Application.SetHighDpiMode(HighDpiMode.<setting>). It is recommended to use SystemAware as the HighDpiMode option for better results.

As I’m not using the HighDpiMode in my application, I can just ignore this warning (see this related Github issue: https://github.com/dotnet/upgrade-assistant/issues/980). If you need to set the HighDpiMode, have a look at the changed bootstrapping logic here: https://docs.microsoft.com/en-us/dotnet/core/compatibility/windows-forms/6.0/application-bootstrap.

Warning – Detected package downgrade

Let’s move on to the next warning:

[WRN] [NuGet] Detected package downgrade: System.ServiceModel.Security from 4.9.0 to 4.8.1. Reference the package directly from the project to select a different version. project -> Microsoft.Windows.Compatibility 6.0.0 -> System.ServiceModel.Security (>= 4.9.0) project -> System.ServiceModel.Security (>= 4.8.1)

These warnings are caused by the Microsoft.Windows.Compability NuGet package. This package will introduce a reference to a lot of other packages(with some System.ServiceModel related dependencies as a part of them).

The original application was using the 4.8.1 versions of those packages. Upgrading to 4.9.0 should not be a problem. This means that this warning will disappear once all projects in the solution are upgraded.

Another one that we can safely ignore. Nice!

Diagnostic UA0002

Another log line that triggered my attention was the following:

Diagnostic UA0002 with the message This type is not supported on .NET Core/.NET 5+ and should be replaced with a modern equivalent’

I had a look at the Analysis.sarif file that was generated as part of the analyze process. Unfortunately that didn’t gave any extra clue on what this message was referring to.

There is an open Github issue related to this: https://github.com/dotnet/upgrade-assistant/issues/1102

So we had to skip this message as I didn’t know what to do.

Diagnostic UA0013_I

The last log message I want to have a look at is the following one:

Diagnostic UA0013_I with the message Windows Forms Deprecated controls : Microsoft.Reporting.WinForms.ReportViewer is no longer supported’

Microsoft provided a solution in the form of an updated ReportViewer WinForms control that can be downloaded from the Visual Studio Marketplace here: https://marketplace.visualstudio.com/items?itemName=ProBITools.MicrosoftRdlcReportDesignerforVisualStudio2022

Popular posts from this blog

Podman– Command execution failed with exit code 125

After updating WSL on one of the developer machines, Podman failed to work. When we took a look through Podman Desktop, we noticed that Podman had stopped running and returned the following error message: Error: Command execution failed with exit code 125 Here are the steps we tried to fix the issue: We started by running podman info to get some extra details on what could be wrong: >podman info OS: windows/amd64 provider: wsl version: 5.3.1 Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM Error: unable to connect to Podman socket: failed to connect: dial tcp 127.0.0.1:2655: connectex: No connection could be made because the target machine actively refused it. That makes sense as the podman VM was not running. Let’s check the VM: >podman machine list NAME         ...

Cache stampede: when our cache turned against us

While investigating some performance issues, we ran into an ASP.NET Core API that cached a fairly expensive aggregation query for 60 seconds. Under normal load, that was fine: one request rebuilds the cache, everyone else reads from it. Under peak load, dozens of requests would arrive in that same expiry window, all see a cache miss, and all fire the same expensive query in parallel. The database didn't like that. That was the moment when our caching layer stopped helping and started hurting. A burst of requests comes in at the same time, all miss the cache, and all go hammer the database or the downstream API at once. That's a cache stampede . The cache was supposed to protect our backend, and for a few hundred milliseconds it did the opposite. Why this happens IMemoryCache.GetOrCreate (and its async sibling) looks like it protects you, but it doesn't add any locking on its own. Look at the naive version: public async Task<Report> GetReportAsync(string key) ...

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup: All credits go to rcaviers who created this list.