为什么我的 .NET 4 应用程序知道 .NET 4 没有安装 [英] Why does my .NET 4 application know .NET 4 is not installed

查看:45
本文介绍了为什么我的 .NET 4 应用程序知道 .NET 4 没有安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前几天我开发了一个针对 .NET 4 的应用程序,并将它 XCOPY 安装到一台 Windows XP 机器上.我告诉机器的所有者他们需要安装 .NET Framework 4 才能运行我的应用程序,他告诉我他安装了(不是可靠的来源).当我运行该应用程序时,我看到一个消息框,提示该应用程序需要 .NET Framework 4,我要安装它吗?单击是"按钮将我带到 Microsoft 网站,单击几下后 .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.

过去,将 .NET 应用程序 XCOPY 安装到未安装正确版本的 .NET 的计算机会导致应用程序在启动时崩溃,并且没有向用户提供任何有用的信息.为什么这次不一样?

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. 它是否内置到我的应用中,因为我的目标是 .NET X?
  2. 目标机器上是否已经安装了某些东西?

我喜欢这个功能.我想确切地知道将来如何利用它.

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

推荐答案

这是一个非常保守的秘密.当您以 .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:

也许有点过于狼吞虎咽,但还是不错的.它在 中有很好的描述这篇博文.

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.

这篇关于为什么我的 .NET 4 应用程序知道 .NET 4 没有安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆