1

I'm thinking of making a simple self-contained .NET application with WPF that can run on any modern Windows system without requiring the end-user to download and install .NET Framework manually.

As far as I know user just need to click on .exe and wait some time until required libraries are installed.

But applications that were compiled for 3.5 use old L&F on most recent Windows.

Is there any way to make applications look like this:

enter image description here

and not like this (if user already has .NET Framework 4+):

enter image description here

turikhay
  • 298
  • 2
  • 8
  • Have you tried [adding a manifest file](https://stackoverflow.com/questions/6050478/how-do-i-create-edit-a-manifest-file)? make sure you have the `SupportedOS` section. – Scott Chamberlain Aug 21 '18 at 15:19
  • @ScottChamberlain I did what's in the "Add supported OS" section of [Jim's answer](https://stackoverflow.com/a/35801660/3252499), but this had no effect. – turikhay Aug 21 '18 at 15:35

1 Answers1

2

Finally I came up with simple solution. My assumption was wrong and it appears .NET Framework actually uses L&F of currently running version, not the targeting one.

  1. Create App.config (Project -> Add -> New Item... -> App configuration (.config))
  2. Paste following:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <startup>
        <!-- Use 4.0 -->
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
        <!-- Use 2.0 - 3.5 -->
        <supportedRuntime version="v2.0.50727" />
      </startup>
    </configuration>
    

.NET Framework will scan <supportedRuntime> until it finds available. List of supported runtimes can be found here.

turikhay
  • 298
  • 2
  • 8