ILRuntime坑之自定义Attribute 参数不支持枚举

ILRuntime.Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly : 'Assembly-Charp, Version=0.0.0.0,Culture=nuetral,PublicKeyToken=null'
主工程定义了这个Attribute

public enum InfoType{
  Log,
  Error,
}

public class InfoAttribute
{
   readonly string Name;
   readonly InfoType Type;
    public InfoAttribute(string name, InfoType type){
         Name = name;
         Type = type;
   }
}

Hotfix里用了这个Attribute

var type = domain.GetType("com.test.TestInfo");
var obj = type.ReflectionType.GetCustomAttribute(typeof(InfoAttribute));
Debug.LogError(obj);
//结果 obj == null

断点查找后发现

namespace ILRuntime.Reflection
{
    static class Extensions
    {
        public static object CreateInstance(this CustomAttribute attribute, IType at, Runtime.Enviorment.AppDomain appdomain)
        // ........
      //attribute.HasConstructorArguments  在vs里报AssemblyResolutionException
  }
}

应该是ILRuntime不支持内部解析报错了
把InfoType 换成int类型就好了
目前不知道怎么支持
坑了一天时间

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容