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