如何检查是否安装了指定版本的.net Framework?

问题描述:

我已经使用Visual Studio 2010以C#语言创建了一个程序.它基于.net framework 3.5版本.我已经使用"INNOSETUP Compiler"为程序创建了一个安装文件.由于我需要在PC上安装.net fw,因此它在我的PC上可以正常工作.我希望安装程序可以与任何安装了.net Framework 3.5或更高版本的Windows PC一起使用.如何检查是否已安装必要的固件版本.如果不是,则用户必须能够从安装文件本身进行安装(我必须在程序安装文件中包括.net fw安装文件).我该怎么办?

我还看到了Visual Studio设置向导,并且我认为它可以做到这一点.但是如何?

在此先感谢您.

I''ve created a program using Visual Studio 2010 in C# language. It is based on the .net framework 3.5 version. I have created a setup file for the program using "INNOSETUP Compiler". It works fine on my pc since I have needed .net fw installed on my pc. I want the setup to be working with any windows pc which has .net framework 3.5 or above instaled. How can I check whether the necessary fw version is installed or not. If not then the user must be able to install it from the setup file itself(i must include the .net fw setup file in the program setup file). How can I do this??

I also saw the visual studio setup wizard and I think it can be able to this for me. But how?

Thanks in advance.

安装向导将生成一个文件,该文件根据应用程序构建版本检查可用版本,并在必要时自动安装更新版本.想一想:如果根本没有安装.NET框架,将会发生什么?在继续进行应用程序安装之前,安装程序将安装适当的版本. :laugh:
The setup wizard will produce a file that checks the available version against the application build version, and will automatically install an updated version if necessary. Think about it: what would have happened if there was no .NET framework installed at all? The setup would install the appropriate version before continuing with the application installation. :laugh:


Innosetup支持自定义代码.您可以使用本文中的代码简单地验证安装的版本: http://www.kynosarges.de/DotNetVersion.html [ ^ ];
此版本仅适用于v3.5,但如果缺少,它可以重定向到Microsoft网站: http://blog.marcduerst.com/post/InnoSetup-Check-for-Net-35.aspx [模块化InnoSetup依赖项安装程序 [ http://www.vbforums.com/showthread.php?637953-Inno-Setup-Check-for-.Net-framework-then-install-it [
Innosetup supports custom code. You can simply verify the installed version using the code from this article: http://www.kynosarges.de/DotNetVersion.html[^];
This one is for v3.5 only, but it has a redirect to Microsoft site if missing: http://blog.marcduerst.com/post/InnoSetup-Check-for-Net-35.aspx[^]
But here you can see the most complete solution: Modular InnoSetup Dependency Installer[^]

Of course, you can pack redistributables if network connection is not available (http://www.vbforums.com/showthread.php?637953-Inno-Setup-Check-for-.Net-framework-then-install-it[^]), but you should enforce downloading if possible.