How to: Configure the .NET Framework 4 Runtime
This topic describes how to configure your .NET Framework applications to run on the .NET Framework version 4 without recompiling them.
To run an application on the .NET Framework 4
To run an add-in on the .NET Framework 4
In the folder that contains the .exe file of your add-in, create an XML file with the following elements:
<configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup> </configuration>
The useLegacyV2RuntimeActivationPolicy attribute for the <startup> Element must be set to true.
Start your application and run the add-in.
To run a Web application on the .NET Framework 4
Precompile your Web application on the computer that is running the earlier version of the .NET Framework that the application was built with. You can do this by running the ASP.NET Compilation Tool, which is located in the [%WinDir%]\Microsoft.Net\Framework\[.NET Framework Version]\ directory, using the following syntax:
aspnet_compiler -v /[ApplicationName] [Destination Directory]
For example, to precompile the Web application named ExampleWebApp and to put the resulting assembly in the C:\WebApps directory, use the following command:
aspnet_compiler -v /ExampleWebApp c:\WebApps
For more information about this process, see How to: Precompile ASP.NET Web Site Projects.
Copy the compiled Web site assembly to a computer that has the .NET Framework 4 installed.
You can also install the Web application that targets an earlier version of the .NET Framework on the computer that has the .NET Framework 4 installed.
Verify that the .NET Framework 4 is installed and enabled. Run the ASP.NET IIS Registration tool by using the following command in the .NET Framework 4 directory:
aspnet_regiis –i –enable
For more information about this tool, see ASP.NET IIS Registration Tool (Aspnet_regiis.exe).
Verify that the application pools target the .NET Framework 4.
The Web application is now configured to run on the .NET Framework 4.
To run a ClickOnce application on the .NET Framework 4
Add a compatibleFrameworks element to your ClickOnce application’s deployment manifest:
<compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2"> <framework profile="Full" targetVersion="4.0" supportedRuntime="4.0.30319" /> </compatibleFrameworks>
If you want your application to run the .NET Framework 4 Client Profile, use the following configuration:
<compatibleFrameworks xmlns="urn:schemas-microsoft-com:clickonce.v2"> <framework profile="Client" targetVersion="4.0" supportedRuntime="4.0.30319" /> </compatibleFrameworks>
For more information about ClickOnce deployment, see <compatibleFrameworks> Element (ClickOnce Deployment)
Update your application’s configuration file to contain the supportedRuntime element:
Update the existing file reference in the application manifest to include the configuration file:
<file name="[application file name].exe.config" size="[config file size]">
Use the Manifest Generation and editing Tool (Mage.exe) to update the hash in the application manifest:
Mage –update [path to application manifest]
For more information about this command, see Mage.exe (Manifest Generation and Editing Tool).
Sign the updated application manifest:
Mage –Sign [path to application manifest] –CertFile [path to .pfx file]
Update the deployment manifest:
Mage –update [path to deployment manifest] –AppManifest [path to application manifest]
Sign the updated deployment manifest:
Mage –Sign [path to deployment manifest] –CertFile [path to .pfx file]
The ClickOnce application is now configured to run on the .NET Framework 4.