我一直在收到错误:
CS1061:'Type'不包含'GetMethod'的定义,并且没有扩展方法'GetMethod'接受类型'Type'的第一个参数(你是否缺少using指令或汇编引用?) .
我正在尝试为Windows应用商店应用构建!
这是我的代码:
MethodInfo theMethod = itween.GetType().GetMethod (animation.ToString(), new Type[] {
typeof(GameObject),
typeof(Hashtable)
});
theMethod.Invoke(this, parameters);
1 回答
要在Windows应用商店应用中使用Reflection,请使用TypeInfo类而不是经典.NET应用程序中使用的Type类 .
但是,它仍然有一些限制:
参考:Reflection in the .NET Framework for Windows Store Apps
与您的代码对应的代码片段如下:
请注意
GetTypeInfo
被定义为扩展方法,因此编译器需要using System.Reflection;
才能识别此方法 .