扩大对Khoth的答案,在AssemblyInfo.cs中:
你可以这样做:
[assembly: CustomResource("Build Date", "12/12/2012")]
凡CustomResource被定义为:
[AttributeUsage(AttributeTargets.Assembly)]
public class CustomResourceAttribute : Attribute
{
private string the_variable;
public string Variable {get { return the_variable; }}
private string the_value;
public string Value {get { return the_value; }}
public CustomResourceAttribute(string variable, string value)
{
this.the_variable = variable;
this.the_value = value;
}
}
这个解决方案是好的,因为它给你需要的灵活性,它不会导致任何编译器警告。
不幸的是,使用DateTime是不可能的,因为在属性中输入的值必须是常量,并且DateTime不是常量。
谢谢 - 显示为“产品版本”,这可能是可以接受的解决方法。我真正喜欢的是能够看到“生成日期”显示为属性的名称。 – Simon 2008-09-23 13:27:35