Problem with Visual Studio installer project and System.Management after .NET 6 upgrade

WUBBSY 21 Reputation points
2022-10-12T15:07:38.117+00:00

Hello,
I've wrote a simple WPF application for my company. It displays system information, installs printers and manages some settings.

Recently I used the Microsoft .NET Upgrade Assistant to upgrade my app from .NET 5 to .NET 6.
After fixing the NuGet package manager, which got broken through the upgrade assist, the app startet as normal and everything seemed fine.
But after Testing the installation the app threw errors and crashed. In my log I got the following error.

System.PlatformNotSupportedException: System.Management currently is only supported for Windows desktop applications.

I use System.Management to get system information and to handle printers.
When I just open the compiled exe, without the installer, the app works just fine without any problems.
I don't get how the installer convinces windows that my WPF GUI app is somehow a .NET Core application.

Sadly I could find many resources to Installer Projects and .NET 6.

  • The App itself is set to Windows Application and .NET 6.0
  • I use "Publish Items" instead of Primary output" in the installer
  • I set the Prerequisites of the installer to ".NET Desktop Runtime 6.0.9 (x64)"

I can't find anywhere to say that this app is a Desktop app and not a Core app.

I created a simple .NET 6 App with a installer and it works with System.Management. But I can't find any differences.
I also added a new installer project to my solution but I get the same error.

The thing that gets me is that when starting the app from the build output it works just fine.

Is there any option that could cause this problem or do I have to rewrite the whole app with .NET 6 from the beginning?

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,364 questions
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,130 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jiachen Li-MSFT 27,001 Reputation points Microsoft Vendor
    2022-10-13T08:15:07.323+00:00

    Hi @WUBBSY ,
    Please check if the following solution helps.
    https://stackoverflow.com/a/71890740/17334287

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful