C# 无法在枚举上设置DisplayName

C# 无法在枚举上设置DisplayName,c#,enums,.net-3.5,C#,Enums,.net 3.5,我使用反编译器从DLL中提取所有代码(SharpSVN——我无法获得源代码),我想修改一个枚举,给它一个DisplayName public enum SvnStatus { Zero, None, [DisplayName("Not Versioned")] NotVersioned, //other one-word values that don't need a display name } 但这给了我以下错误: 属性“System.ComponentModel.D

我使用反编译器从DLL中提取所有代码(SharpSVN——我无法获得源代码),我想修改一个枚举,给它一个DisplayName

public enum SvnStatus
{
  Zero,
  None,
  [DisplayName("Not Versioned")]
  NotVersioned,
  //other one-word values that don't need a display name
}
但这给了我以下错误:

属性“System.ComponentModel.DisplayNameAttribute”对此声明类型无效。它仅对“类、方法、属性、事件”声明有效。

谷歌搜索了一下,发现了很多线程,在这些线程中,人们似乎对自己的枚举没有问题。我错过什么了吗?我无法
解决Visual Studio中的错误,该选项甚至没有显示(但这可能是因为我刚刚安装了Resharper,还不熟悉它?)


编辑:刚发现DevExpress有一个
CustomColumnDisplayText
事件,我可以根据需要更改值,因此我将使用该事件,因为数据仅显示在GridControl中。

原因在您收到的错误中给出

System.ComponentModel.DisplayNameAttribute
已被属性化,该属性将用法限制为仅应用于类、方法、属性或事件。不包括枚举。看起来是这样的:

[AttributeUsageAttribute(AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event)]


也许您可以编写自己的属性?

我不明白的是,为什么这样的东西会在枚举中使用DisplayName属性。我还看到它被用在其他一些问题上。我可以只使用
[Description]
属性吗?不幸的是,反编译出现了一些问题,我甚至无法构建它给我的解决方案,所以我想我是索尔。他没有使用
DisplayName
属性,他显然使用了一个名为
Display
的属性。哦,对了,对不起,我看到了
[Display(Name=”“])
[DisplayName(“”)
在不同的地方,但都不适合我。