turikhay
turikhay

Reputation: 297

How to force WPF app for .NET Framework 3.5 use newer L&F?

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

Upvotes: 1

Views: 568

Answers (1)

turikhay
turikhay

Reputation: 297

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.

Upvotes: 2

Related Questions