为什么我的.NET 4的应用程序知道.NET 4中未安装我的、应用程序、中未、NET

2023-09-02 01:20:09 作者:别打感情牌

我制定了有针对性的.NET 4有一天,XCOPY安装到Windows XP机器的应用程序。我告诉他们需要安装.NET Framework 4运行我的应用程序的机器的拥有者,他告诉我他做(不是一个可靠的来源)。当我运行应用程序我是psented一个消息框,说这个程序需要.NET Framework 4中,我想安装$ P $?如果选择是,带我去微软的网站,并点击几下后.NET 4的安装和应用程序成功启动。

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.

在过去,XCOPY,安装.NET应用程序的机器上没有安装正确版本的.NET导致应用程序psented用户没有任何有用的信息$ P $崩溃的启动。为什么会不同,这一次?

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?

是它内置到我的应用程序,因为我的目标.NET X' 是它在目标机器上已经安装了什么?

我喜欢的功能。我想知道precisely如何利用它的未来。

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

推荐答案

这是一个pretty的保存完好的秘密。当你面向.NET 4的用户运行应用程序时没有安装.NET 4中就会出现这种情况。或者当你的目标是早期的版本,运行在Windows 8的应用程序,用户将看到这个对话框:

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:

一个有点太gobbledegooky也许,但仍然不错。它是在this博客文章。

A bit too gobbledegooky maybe but nice nonetheless. It is described well in this blog post.

请记住,.NET 4有一个最低的Windows版本和服务包的要求。最低金额是XP SP3,Vista SP1的,Win7的RTM。所以,这不是一个神奇的解决方案,以获得安装了正确的服务包。

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.