【发布时间】:2018-06-08 22:44:21
【问题描述】:
我正在尝试使用 Mono.Cecil 向程序集添加新的属性类型。
我希望它看起来像:
internal class ConfusedByAttribute : Attribute
{
}
但目前我得到了相同的结果,只是没有 : Attribute (System.Attribute) 部分。
这是我的代码:
var assemblyDef = AssemblyDefinition.ReadAssembly(args[0]);
var tp = new TypeDefinition(
"",
"ConfusedByAttribute",
Mono.Cecil.TypeAttributes.NestedPrivate);
assemblyDef.MainModule.Types.Add(tp);
assemblyDef.Write(args[0] + "neW");
感谢任何帮助,谢谢!
【问题讨论】:
-
那么问题出在哪里?你有例外吗?请阅读如何创建Minimal, Complete, and Verifiable example
标签: c# mono code-injection mono.cecil