问题描述
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?
- Was it built into my app because I targeted .NET X?
- 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.
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.
这篇关于为什么我的 .NET 4 应用程序知道未安装 .NET 4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!