如何检测 .NET Framework 功能何时“关闭”?在 Windows 7/Vista 中?
我的应用程序需要 .NET Framework 版本 3.5。我最近遇到一位安装了 .NET Framework 的客户,但 在 Windows Vista 上关闭(也适用于 Windows 7)。
在这种情况下,我的安装程序(InstallShield 2009)不会提示用户安装框架(因为它已经安装),并且当我的应用程序运行时它会立即崩溃。我尝试了另一个 .NET 应用程序,它也立即崩溃。
有没有办法检测这种情况并更妥善地处理它?</strong>仅在安装过程中检测这种情况并不理想,因为 .NET Framework 可以随时关闭。理想情况下,应用程序能够检查并向用户显示一条友好的消息,告诉他们需要打开 .NET Framework。
编辑:在 Windows Vista 或 Windows 7 中“关闭”.NET Framework 与卸载它不同。无需重新安装即可简单地重新打开框架:http://windows.microsoft.com/en-US/windows-vista/Turn-Windows-features-on-or-off
My application requires the .NET Framework version 3.5. I recently ran into a customer that had the .NET Framework installed but turned off on Windows Vista (also applies to Windows 7).
In this case, my installer (InstallShield 2009) does not prompt the user to install the Framework (because it is already installed) and when my application runs it crashes immediately. I tried another .NET application and it also crashes immediately.
Is there any way to detect this situation and handle it more gracefully? Just detecting this during install is not ideal since the .NET Framework can be turned off at any time. Ideally, the application would be able to check and display a friendly message to the user telling them they need to turn on the .NET Framework.
EDIT: "Turning off" the .NET Framework in Windows Vista or Windows 7 is not the same as uninstalling it. The Framework can be simply turned back on without reinstalling: http://windows.microsoft.com/en-US/windows-vista/Turn-Windows-features-on-or-off
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当我关闭该功能时,注册表中指示框架已安装的值被删除。您可以检查该值。
看看:
HKLM\Software\Microsoft\NET Framework 安装程序\NDP\v3.5
When I turned off the feature, the value in the registry that indicated the framework is installed got deleted. You could check that value.
Take a look at:
HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5
看起来您要为您的应用程序编写一个非托管启动器。卷起袖子,来一次愉快的 C++ 探索吧:)
Looks like you're going to write a non-managed launcher for your app. Roll up your sleeves and have a nice C++ dive :)
哇,我想这个网址可能有你的答案:
http:// /blogs.msdn.com/astebner/archive/2008/04/04/8358995.aspx
请参阅“如何在部署方案中安装 .NET Framework 3.0 操作系统组件”。据我所知,它描述了使用 ocsetup 触发 Windows 打开该功能。祝你好运。
另外,我很好奇 ClickOnce 安装程序是否智能地知道该功能是否已关闭(我想他们会关闭)。但由于您使用的是 InstallShield,您可能需要一个比 clickonce 功能更齐全的安装程序;o)
Woot, I think this URL might have your answer:
http://blogs.msdn.com/astebner/archive/2008/04/04/8358995.aspx
See "How to install the .NET Framework 3.0 OS component in a deployment scenario". It describes using ocsetup to trigger Windows to turn the feature on, as far as I can tell. Best of luck.
Also, I'm curious if ClickOnce installers are intelligent to know if the feature is turned off (I imagine they would be). But since you're using InstallShield you probably want a more fully-featured installer than clickonce ;o)