Exception in deployment, not when run from Release folder (JSON File Missing)

277 views Asked by At

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?

1

There are 1 answers

0
Mike Mozhaev On

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.