以编程方式确定是否已安装.NET 3.0 [英] Programmatically determine if .NET 3.0 is installed

查看:98
本文介绍了以编程方式确定是否已安装.NET 3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个广泛分发的Web应用程序,我不知道

安装的.NET Framework版本。如果安装了,我想利用一些.NET 3.0

类,但如果不可用则优雅地降级。

(具体来说,我想使用System.Windows。 Media.Imaging.BitmapMetadata

在3.0可用时从JPEG文件中提取元数据,但如果没有安装.NET 3.0,则会使用

System.Drawing.Image。)


确定.NET 3.0是否安装了
的最佳建议是什么?该解决方案必须在中型信任环境中运行。我不是

确定是否有用于查询此信息的框架类,或者我应该只是尝试访问该类并让异常告诉我它不可用。


我发现System.Environment.Version.ToString()在我的电脑上给出了2.0.50727.1378

,所以这没有帮助。 (除非1378表示3.0是安装的b $ b,但我对此表示怀疑。)


谢谢!

Roger马丁

解决方案

对不起,我需要确定在网络服务器上运行的版本,

不在客户浏览器。正常的方法是让代码隐藏参考给System.Environment.Version.ToString()
,但正如我所提到的那样,返回

2.0.50727.1378,即使我安装了3.0。


您是否在MSDN上看到此页面?

http://msdn2.microsoft.com/en-us/library/ms749404.aspx


彼得

-

递归:见递归

网站: http://www.eggheadcafe.com

unBlog: http://petesbloggerama.blogspot.com

bogMetaFinder: http://www.blogmetafinder.com

Roger Martin写道:


我正在编写一个广泛分发的网络应用程序,我不知道

安装的.NET Framework版本。如果安装了,我想利用一些.NET 3.0

类,但如果不可用则优雅地降级。

(具体来说,我想使用System.Windows。 Media.Imaging.BitmapMetadata

在3.0可用时从JPEG文件中提取元数据,但如果没有安装.NET 3.0,则会使用

System.Drawing.Image。)


确定.NET 3.0是否安装了
的最佳建议是什么?该解决方案必须在中型信任环境中运行。我不是

确定是否有用于查询此信息的框架类,或者我应该只是尝试访问该类并让异常告诉我它不可用。


我发现System.Environment.Version.ToString()在我的电脑上给出了2.0.50727.1378

,所以这没有帮助。 (除非1378表示3.0是安装的b $ b,但我对此表示怀疑。)


谢谢!

Roger Martin


这是我引用给他的代码,彼得,但他想要服务器端检测。


这里是如何在Visual Studio安装和部署包中检测网络框架版本:

http://support.microsoft.com/kb/315291

Aaron Stebner在这里有很多有用的C ++代码:
http://astebner.sts.winisp .net / Tools / detectFX.cpp.txt

将其迁移到C#或VB.NET看起来并不太难。


此外,还有很好的C#代码示例:
http://www.codeproject.com/useritems...ndetection.asp

Juan T. Llibre,asp.net MVP

asp.net faq: http://asp.net.do/ faq /

foros de asp.net,en espa?ol: http://asp.net.do/foros/

====================== ================

Peter Bromberg [C#MVP]" < pb ******* @ yahoo.yohohhoandabottleofrum.com写信息

news:20 ********************* ************* @ microsof t.com ...


您是否在MSDN上看到此页面?

http://msdn2.microsoft.com/en -us / library / ms749404.aspx


Peter

-

递归:参见递归

网站: http://www.eggheadcafe.com

unBlog: http://petesbloggerama.blogspot.com

bogMetaFinder: http://www.blogmetafinder.com


" Roger Martin"写道:


>我正在编写一个广泛分发的网络应用程序,我不知道安装的.NET Framework版本。我想利用一些.NET 3.0
类,如果它们已安装,但如果不可用则优雅地降级。
(具体来说,我想使用System.Windows.Media.Imaging.BitmapMetadata来
建议的最佳确定方法是什么是否安装了.NET 3.0?该解决方案必须在中型信任环境中运行。我不确定是否有用于查询此信息的框架类,或者我是否应该尝试访问该类并让异常告诉我它不可用。

我发现System.Environment.Version.ToString()在我的电脑上给出了2.0.50727.1378
,所以这没有用。 (除非1378表示安装了3.0,但我对此表示怀疑。)

谢谢!
Roger Martin



I am writing a web app to be widely distributed where I do not know the
installed .NET Framework version. I want to take advantage of some .NET 3.0
classes if they are installed, but gracefully degrade if not available.
(Specifically, I want to use System.Windows.Media.Imaging.BitmapMetadata to
extract metadata from JPEG files when 3.0 is available, but will resort to
System.Drawing.Image if .NET 3.0 is not installed.)

What is the recommended best practice for determining whether .NET 3.0 is
installed? The solution must work in a Medium Trust environment. I am not
sure if there is a framework class for querying this info or if I should just
try accessing the class and let the exception tell me it is not available.

I have found that System.Environment.Version.ToString() gives 2.0.50727.1378
on my PC, so that doesn''t help. (Unless the "1378" indicates that 3.0 is
installed, but I doubt it.)

Thanks!
Roger Martin

解决方案

I am sorry, but I need to determine the version running on the web server,
not on the client browser. The normal way would be to have code-behind refer
to System.Environment.Version.ToString(), but as I mentioned this returns
2.0.50727.1378, even when I have 3.0 installed.


Did you see this page on MSDN?

http://msdn2.microsoft.com/en-us/library/ms749404.aspx

Peter
--
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"Roger Martin" wrote:

I am writing a web app to be widely distributed where I do not know the
installed .NET Framework version. I want to take advantage of some .NET 3.0
classes if they are installed, but gracefully degrade if not available.
(Specifically, I want to use System.Windows.Media.Imaging.BitmapMetadata to
extract metadata from JPEG files when 3.0 is available, but will resort to
System.Drawing.Image if .NET 3.0 is not installed.)

What is the recommended best practice for determining whether .NET 3.0 is
installed? The solution must work in a Medium Trust environment. I am not
sure if there is a framework class for querying this info or if I should just
try accessing the class and let the exception tell me it is not available.

I have found that System.Environment.Version.ToString() gives 2.0.50727.1378
on my PC, so that doesn''t help. (Unless the "1378" indicates that 3.0 is
installed, but I doubt it.)

Thanks!
Roger Martin


That''s the code I quoted to him, Peter, but he wants server-side detection.

Here''s how to detect the net framework version in a Visual Studio Setup and Deployment package:

http://support.microsoft.com/kb/315291

Aaron Stebner has useful C++ code to do that here :
http://astebner.sts.winisp.net/Tools/detectFX.cpp.txt

Migrating that to C# or VB.NET doesn''t look too difficult.

Also, there''s good C# code examples at :
http://www.codeproject.com/useritems...ndetection.asp

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
======================================
"Peter Bromberg [C# MVP]" <pb*******@yahoo.yohohhoandabottleofrum.comwrote in message
news:20**********************************@microsof t.com...

Did you see this page on MSDN?

http://msdn2.microsoft.com/en-us/library/ms749404.aspx

Peter
--
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
bogMetaFinder: http://www.blogmetafinder.com

"Roger Martin" wrote:

>I am writing a web app to be widely distributed where I do not know the
installed .NET Framework version. I want to take advantage of some .NET 3.0
classes if they are installed, but gracefully degrade if not available.
(Specifically, I want to use System.Windows.Media.Imaging.BitmapMetadata to
extract metadata from JPEG files when 3.0 is available, but will resort to
System.Drawing.Image if .NET 3.0 is not installed.)

What is the recommended best practice for determining whether .NET 3.0 is
installed? The solution must work in a Medium Trust environment. I am not
sure if there is a framework class for querying this info or if I should just
try accessing the class and let the exception tell me it is not available.

I have found that System.Environment.Version.ToString() gives 2.0.50727.1378
on my PC, so that doesn''t help. (Unless the "1378" indicates that 3.0 is
installed, but I doubt it.)

Thanks!
Roger Martin



这篇关于以编程方式确定是否已安装.NET 3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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