5
votes

We have an application that supports both .NET 2.0 and .NET 4.0 and we switch the few framework dependent assemblies with <bindingRedirect />. We've used the <supportedRuntime /> element to allow the application to run using the latest framework if available. However, we do still require the full profile, not just the client profile.

The documentation for .NET 3.5 indicates that you must explicitly opt-in to client only support by adding a sku="client" attribute to the <supportedRuntime /> element.

The sku attribute name is case-sensitive. If the sku attribute is missing, or if its value is set to anything other than "client", the runtime assumes the application is not a .NET Framework Client Profile application.

However, with .NET 4.0 detailed documentation on the sku attribute is missing. In our tests the .NET runtime will use the .NET 4.0 client profile even if the sku attribute is missing. This is a problem since it doesn't allow dynamic redirection with the .config file. I've tried to use sku="full" to try and force it to only use the full profile but that just results in no .NET 4.0 runtime being supported.

The question

Does anyone know of a way to force the use of the full .NET profile when using <supportedRuntime /> (or other comparable solution) to support multiple .NET framework versions?

Snippet from our .config file

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup>
        <supportedRuntime version="v4.0.30319" />
        <supportedRuntime version="v2.0.50727" />
    </startup>

    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" 
                         appliesTo="v4.0.30319">

            <dependentAssembly>
                <assemblyIdentity name="Application"
                                  publicKeyToken="798276055709c98a"
                                  />

                <bindingRedirect oldVersion="4.1.2000.0"
                                 newVersion="4.1.4000.0" />

                <codeBase version="4.1.4000.0"
                          href="Redistributable\.NET 4.0\Application.dll" />

            </dependentAssembly>
         </assemblyBinding>
    </runtime>
</configuration>
2

2 Answers

4
votes

My understanding is this would work:

<supportedRuntime version="v4.0.30319" sku=".NETFramework,Version=v4.0.1" />
<supportedRuntime version="v4.0.30319" sku=".NETFramework,Version=v4.0" />

There is no Profile=Full, but the Profile is meant to restrict to a smaller SKU per my understanding.

The list of installed SKUs can be found at

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs
0
votes

According to the updated .NET 4.5 & 4.6 MSDN page for <supportedRuntime> Element, there is a "Profile" option for the sku attribute, and while the only value for it is "Client", not having it seems to imply "Full"-only (according to the sku chart on that page). So you should be good with the following:

<startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
    <supportedRuntime version="v2.0.50727" />
</startup>

Please note that according to that linked MSDN page:

Beginning with the .NET Framework 4, only the major and minor version numbers are required (that is, "v4.0" instead of "v4.0.30319"). The shorter string is recommended.