Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 是否有类似于.NET web DLL的Application.ProductVersion的内容?_C#_Asp.net_.net_Web Services_Wcf - Fatal编程技术网

C# 是否有类似于.NET web DLL的Application.ProductVersion的内容?

C# 是否有类似于.NET web DLL的Application.ProductVersion的内容?,c#,asp.net,.net,web-services,wcf,C#,Asp.net,.net,Web Services,Wcf,我想获取我的.NET web应用程序或web服务的版本-从AssemblyInfo.cs在DLL上显示的版本-并且很乐意获取其他程序集信息,如公司和版权 在Windows应用程序中,这很简单,只需执行Application.ProductVersion即可获得版本。web应用/服务是否也有类似的功能?类似System.Web.App.Version的内容 谢谢 对于程序集中要从中获取版本的任何类型,都可以按如下方式获取版本: typeof(SomeType).Assembly.GetName()

我想获取我的.NET web应用程序或web服务的版本-从AssemblyInfo.cs在DLL上显示的版本-并且很乐意获取其他程序集信息,如公司和版权

在Windows应用程序中,这很简单,只需执行Application.ProductVersion即可获得版本。web应用/服务是否也有类似的功能?类似System.Web.App.Version的内容


谢谢

对于程序集中要从中获取版本的任何类型,都可以按如下方式获取版本:

typeof(SomeType).Assembly.GetName().Version
对于其他内容,如公司和版权,您必须直接查找程序集级属性。以下是版权的一个例子:

object[] attributes = typeof(SomeType).Assembly
    .GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);

AssemblyCopyrightAttribute attribute = null;
if (attributes.Length > 0)
{
   attribute = attributes[0] as AssemblyCopyrightAttribute;
}

var companyName = attribute.Company;