简体   繁体   English

获取我的应用程序的当前点网版本

[英]Get the current dot net version of my application

How do I get the running dot net version of my asp.net application. 如何获得我的asp.net应用程序的运行点网版本。

I tried the solution from here 我从这里尝试了解决方案

Is there an easy way to check the .NET Framework version? 有没有简单的方法来检查.NET Framework版本?

It gives the highest version installed but I need the running version. 它提供了最高版本,但我需要运行版本。

Use Environment.Version for getting the run time version. 使用Environment.Version获取运行时版本。 It will give the version number of .Net CLR which is being used for executing current application. 它将给出用于执行当前应用程序的.Net CLR的版本号。

You need to be careful here, it will only return run time version not framework version. 你需要在这里小心,它只返回运行时版本而不是框架版本。 The CLR for .NET 3.0 and .NET 3.5 is the same CLR from .NET 2.0. .NET 3.0和.NET 3.5的CLR与.NET 2.0中的CLR相同。

使用Environment.Version - 它为您提供运行应用程序的.NET的确切版本。

Hope this one helps, 希望这个有帮助,

DirectoryEntry site = new DirectoryEntry(@"IIS://localhost/w3svc/1/Root");
PropertyValueCollection values = site.Properties["ScriptMaps"];
foreach (string val in values)
{
    if (val.StartsWith(".aspx"))
    {
        string version = val.Substring(val.IndexOf("Framework") + 10, 9);
        MessageBox.Show(String.Format("ASP.Net Version is {0}", version));
    }
}

The script map property is an array of strings. 脚本映射属性是一个字符串数组。 If the app supports asp.net one of those strings will be a mapping of the aspx file extension to the asp.net handler which will a the full path to a DLL. 如果应用程序支持asp.net,那么其中一个字符串将是aspx文件扩展名到asp.net处理程序的映射,这将是DLL的完整路径。 The path will be something like 路径将是这样的

%windir%/Microsoft.NET/Framework//aspnet_isapi.dll. %WINDIR%/ Microsoft.NET /框架// ASPNET_ISAPI.DLL。

You can get the version out of this string with some simple parsing. 您可以通过一些简单的解析来获取此字符串的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM