When using. net to develop desktop applications, client deployment is the biggest headache for the majority of users. Based on. net 2.0 winfrom program because the distribution package size of the Framework is about 20 mb, unfortunately, if the project uses technologies such as Wcf and wpf, that is more than 350 MB. net 3.5 sp1 can make you cry. Although many. net 3.5 packages are circulating, they are not official solutions.
Win7 comes with. net 3.5 sp1, and the installation volume of win7 is already high, so we can upgrade the project to. net 3.5.
Objectives:
Based on. net 3.5 development applications, in win7 or installed. net 3.5 sp1 can be directly installed and run on other machines. net 4.0 framework, so that.. net 3.5 applications run in. net 4.0 framework.
The solution in this article is as follows:
1. The project's target framework is. net 3.5.
2. Client deployment uses the. net 4.0 Framework instead of 3.5 sp1; 4.0 of the distribution package is 48 MB.
3. If the system is installed with. net 3.5 sp1, the 4.0 framework is not installed.
Problems to be Solved:
1. First, you must enable the applications written in. net 3.5 to run in the. net 4.0 environment.
We can add the following configuration section in app. config:
<Startup useLegacyV2RuntimeActivationPolicy = "true">
<SupportedRuntime version = "v4.0"/>
</Startup>
This node indicates
Indicates to run the program using the. NET4.0 runtime. For more information about startup, see Msdn.
In this way, we can run applications written in. net 4.0 on a machine with only. net 3.5 installed.
Wait. If the above settings run on a machine that only has the. net3.5 framework installed but does not have the. net 4.0 framework, the following error will be reported:
"Sorry, this is not the result I want! ", The solution is as follows:
<Startup useLegacyV2RuntimeActivationPolicy = "true">
<SupportedRuntime version = "v4.0"/>
<SupportedRuntime version = "v2.0.50727"/>
</Startup>
The red part is newly added to specify that the software can be run in v2.0.50727. (Ps: the clr runtime environment of. net 3.5 is 2.0)
The Oh oh target has been reached. Now the software can be run on a machine that only installs. net 4.0 or only installs. net 3.5.
2. When installing the software, first check whether the system has installed. net 3.5. If it is not installed, install the. net 4.0 framework. Otherwise, skip the running environment I check and only install the software.
This document uses Advanced Installer 7.2 to create an installation package.
This document does not describe the specific production process of the installation package. If you are interested, You can google it. The following section only describes the settings of the "running environment.
Click the "Create running environment" dialog box as shown in the following figure:
Note: In the "Installation File"-> "website", it should be.. net 4.0 installation package address, not. net 3.5 sp1 address, of course, we can also select "files in the package" in the location, select local. net 4.0 framework Installation File.
Next, set "installation conditions ":
Check whether. net 3.5 sp1 installation conditions are set by default in the installation conditions. Check the registry key:
HKLM \ SOFTWARE \ Microsoft \ NET Framework Setup \ NDP \ v3.5 \ SP
We need to add a registry check item to check whether. net 4.0 is installed:
HKLM \ SOFTWARE \ Microsoft \ NET Framework Setup \ NDP \ v4 \ Full \ Install
OK. Now the runtime environment settings are complete.
From the blue sky behind the white clouds