1

C# .NET 6.0 WinForms x64bit Desktop application

Application exe runs fine via the project's "x64\Release" folder.

We deliver via an MSI created via "Setup and Deployment Tool". When the application is installed via the MSI file, the user gets an exception as the application launches.

System.PlatformNotSupportedException: System.Management currently is only supported for Windows desktop applications. at System.Management.ManagementBaseObject..ctor(SerializationInfo inf, StreamingContext context)

I've tracked this down to a difference in the file: MyApp.deps.json between the "Release" folder and the installed destination "Program Files" folder.

If I copy that "Release" .json file to the "Program Files..." location, the application runs fine.

What's going on with the Setup and Deployment MSI creator? How can I fix this?

Mark Malburg
  • 125
  • 1
  • 9
  • Could you please provide some details about your setup project? What do you have in `Application Files`? – Mike Mozhaev Feb 01 '23 at 20:33
  • Also what is in your `*.deps.json` file? – Mike Mozhaev Feb 01 '23 at 20:40
  • The JSON (sterilized) contains the following: MyApplication/1.0.0": { }, "DynamicInterop/0.9.1": { ... }, "Microsoft.Bcl.AsyncInterfaces/5.0.0": { ... }, "Microsoft.CSharp/4.7.0": { ... }, "Microsoft.Extensions.ObjectPool/5.0.10": { ... }, "Microsoft.Office.Interop.PowerPoint/15.0.4420.1018": { ... }, "Microsoft.Win32.Registry/4.7.0": { ... }, "Microsoft.Win32.Registry.AccessControl/6.0.0": { ... }, "Microsoft.Win32.SystemEvents/6.0.0": { ... }, ... – Mark Malburg Feb 03 '23 at 14:13
  • Do you have System.Management.dll in application installation folder? Please check https://stackoverflow.com/questions/71889913/how-to-fix-system-management-is-supported-on-windows-desktop-apps-only-excepti/71890740#71890740 – Mike Mozhaev Feb 03 '23 at 14:22
  • System.Management.dll is in the "bin\x64\Release\net6.0-windows folder. I'm not sure what dictates this. Therefore (I'm assuming) that is is part of the "Publish Items from MyApplication (Active)" that appears in the setup and deployment file system. – Mark Malburg Feb 03 '23 at 21:25
  • Application folder for the setup project has: InstallationBanner.jpg LicenseFile.rtf MyApplication.deps.json // I manually added because of this problem Publish Items from MyApp (Active) – Mark Malburg Feb 03 '23 at 21:27

1 Answers1

1

Runtime Configuration Files:

MyApp.deps.json - A list of dependencies, compilation dependencies and version information used to address assembly conflicts. Not technically required, but required to use the servicing or package cache/shared package install features, and to assist during roll-forward scenarios to select the newest version of any assembly that exists more than once in the application and framework(s). If the file is not present, all assemblies in the current folder are used instead.

So you'd better have it deployed with your application.

Regarding the issue. Do you use publish profile? Please check if you specified it in PublishProfilePath, as described in Visual Studio Installer Projects Extension and .NET 6.0

Also you can check what do you have in you publish folder and try to configure the publish profile to have everything you need there.

Mike Mozhaev
  • 2,367
  • 14
  • 13