24

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?

  1. Was it built into my app because I targeted .NET X?
  2. Was it something already installed on the target machine?

I love the feature. I want to know precisely how to leverage it in the future.

Tergiver
  • 14,171
  • 3
  • 41
  • 68

1 Answers1

22

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:

enter image description here

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.

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • I have clients that still use Windows 2000 which is why the vast majority of my apps are 2.0. But this was observed on an XP machine, not 7. Can you explain that? – Tergiver Apr 05 '12 at 17:28
  • Article states that it's Windows 7 and earlier - so XP is included. It says simply that the user experience for this error is improved with Framework 4.5 on Windows 8. – rskar Apr 05 '12 at 17:29
  • 2
    There is even more information in this MSDN article. http://msdn.microsoft.com/en-us/library/w671swch.aspx – djdanlib Apr 05 '12 at 17:35
  • @HansPassant On Win7 without .NET v4.0 I am seeing _very_ similar message to the one in your answer when trying to run v4.0 app, but the "Would you like to ..." section is replaced by "Contact your application publisher for instructions about obtaining the appropriate version of the .NET Framework". And there is only OK button, any idea why? Is this behaviour possibly dependent on some win update or similar ... ? FYI on different win7 machine this was working fine and my app config contains ``. – Michal Hosala Oct 31 '14 at 16:46