title: Runtime error "BadImageFormatException: Cannot load file or assembly for execution. Reference assemblies should not be loaded""
body: <p>I have a C# Winforms desktop project targeting .NetFramework 4.8 which I run with VS 2022. The project builds and runs OK within VS 2022. The project has a number of Nuget packages loaded by with PackageReference rather than Packages.config. The project runs OK in VS 2022 and if I click on the .exe file in Debug/bin using the account in which VS2022 runs. If I create an installer project to create an msi file using the primary output of the main project,and click on the msi file from another account on the same machine, the installation runs OK and the application starts when I click on the executable but throws the error &quot;BadImageFormatException: Cannot load file or assembly for execution. Reference assemblies should not be loaded for execution&quot; when accessing one of the Nuget references added as PackageReference. Looking at the Detected dependencies for the install project, the Nuget components loaded as PackageReference have the same icon ( a small and a larger square connected by a horizontal line) as other components (such as System.Drawing) but for the main project the icons are different ( a blue rounded square containing 2 white disks).</p>
  <p>Is there some property of the items listed in Detected Dependencies of the install project which stops the item from being loaded? I have tried changing PackageAs from vsdpaDefault to vsdpaLoose but this does not fix the problem.</p>