assemblyinfo.cs 文件具有 AssemblyVersion 属性,但是当我运行以下命令时:
Attribute[] y = Assembly.GetExecutingAssembly().GetCustomAttributes();
我得到:
System.Runtime.InteropServices.ComVisibleAttribute
System.Runtime.CompilerServices.RuntimeCompatibilityAttribute
System.Runtime.CompilerServices.CompilationRelaxationsAttribute
System.Runtime.InteropServices.GuidAttribute
System.Diagnostics.DebuggableAttribute
System.Reflection.AssemblyTrademarkAttribute
System.Reflection.AssemblyCopyrightAttribute
System.Reflection.AssemblyCompanyAttribute
System.Reflection.AssemblyConfigurationAttribute
System.Reflection.AssemblyFileVersionAttribute
System.Reflection.AssemblyProductAttribute
System.Reflection.AssemblyDescriptionAttribute
但是我已经无数次检查了这个属性是否存在于我的代码中:
[assembly: AssemblyVersion("5.5.5.5")]
...如果我尝试直接访问它,我会得到一个异常:
Attribute x = Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyVersionAttribute)); //exception
我想我将无法使用该属性,但.NET 为何不读取它?