SuppressIldasmAttribute 属性的使用和去掉
在类的前面定义,添加如下代码:
using System.Runtime.CompilerServices;
[assembly: SuppressIldasmAttribute()]
public class Test
{
....
}
或者在assemblyinfo.cs中添加
[assembly: SuppressIldasm]
编译之后,用正常的ildasm不能打开, 要修改ildasm.exe中的字符串,具体参考:
http://www.rainsts.net/article.asp?id=680
使用ultraedit编译ildasm.exe,搜索字符串,随便改一下,保存为新的ildasm2.exe即可.
当然也可以使用mono.cecil删除这个属性和其它属性:
public static void Main(string[] args)
{
var assembly = AssemblyFactory.GetAssembly("1.exe");
foreach (CustomAttribute attribute in assembly.CustomAttributes)
{
if (attribute.Constructor.DeclaringType.Name == "SuppressIldasmAttribute")
{
assembly.CustomAttributes.Remove(attribute);
break;
}
}
assembly.Name.PublicKey = null;
assembly.Name.PublicKeyToken = null;
AssemblyFactory.SaveAssembly(assembly, "11.exe");
}
具代码参考:
http://www.rainsts.net/article.asp?id=682