I developed an application that targeted .NET 4 the other day and XCOPY-installed it to a Windows XP machine. I had told the owner of the machine that they would need to install .NET Framework 4 to run my app and he told me he did (not a reliable source). When I ran the application I was presented with a message box that said this app requires .NET Framework 4, would I like to install it? Clicking the Yes button took me to the Microsoft web site and a few clicks later .NET 4 was installed, and the application successfully launched.
In the past, XCOPY-installing .NET applications to a machine that didn't have the correct version of .NET installed resulted in the application crashing on startup with no useful information presented to the user. Why was it different this time?
I love the feature. I want to know precisely how to leverage it in the future.
Open Start. Search for Command Prompt, right-click the top result, and select the Run as administrator option. Type the following command to determine the version of . NET installed and press Enter: reg query "HKLM\SOFTWARE\Microsoft\Net Framework Setup\NDP" /s To make sure that version 4.
Select Start > Control Panel > Programs > Programs and Features. Select Turn Windows features on or off. If not already installed, select Microsoft . NET Framework and click OK.
The version of .NET Framework (4.5 and later) installed on a machine is listed in the registry at HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full. If the Full subkey is missing, then .NET Framework 4.5 or above isn't installed.
This is a pretty well kept secret. It will happen when you target .NET 4 and the user runs the app when .NET 4 isn't installed. Or when you target an earlier version and run the app on Windows 8. The user will see this dialog:
A bit too gobbledegooky maybe but nice nonetheless. It is described well in this blog post.
Do keep in mind that .NET 4 has a minimum Windows version and service pack requirement. Minimums are XP SP3, Vista SP1, Win7 RTM. So this is not a magic solution to getting the right service pack installed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With