title: Failure to publish C# application using Produce a Single File option
body: <p>I have created a small application to deploy on a remote computer. The application compiles and runs locally in Visual Studio.
  I publish locally without &quot;Produce single file&quot; ticked and the resulting .exe works fine when I test it on my computer, and when I copy the published folder to a remote computer, again it works fine.
  If I then tick &quot;produce single file&quot; option, the .exe throws &quot;Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
  at TestComputer.Program.Main(String[] args)&quot;. This happens both locally and when I copy it to a remote computer.</p>
  <p>I wish to deploy the software without all the dlls exposed.</p>
  <p>Details:
  Developer environment:
  Visual Studio Community 2019
  Version 16.10.3
  .Net Framework 4.8.04084
  Language c#
  Publish Profile:
  Delete existing files: (false) - however I clear the publish folder each time I publish
  Configuration: Active (Release)
  Platform: Active (Any CPU)
  Define Trace constant: Ticked
  Nullable: Disabled
  Treat warnings as errors: None
  Target Framework: net5.0
  Deployment mode: Self-contained
  Target Runtime: win-x64
  Produce single file: ticked
  Enable ReadyToRun compilation: not ticked
  Trim unused assemblies: Ticked</p>
  <p>Not sure what other information I can provide.</p>
  <p>Summary: I select &quot;Produce single file&quot; to reduce the number of deployable files, and it fails; I unselect &quot;Produce single file&quot; and it works</p>
  <p>Question:
  What settings must I change to enable me to use the &quot;Produce Single File&quot; option when publishing my software for remote deployment?</p>
  <p>Comments:
  Any help or suggestions would be most appreciated.</p>