Portable Class library and reflection

后端 未结 2 1547
忘了有多久
忘了有多久 2020-12-06 05:46

I am building new application for Desktop, Windows 8 store and Windows phone at the same time. so I created Portable Class library to have common functionality across all pl

2条回答
  •  一向
    一向 (楼主)
    2020-12-06 06:48

    To provide some info about my comment use Type.GetMethod.

    Metadata from Type

    When evaluating metadata returned from System.Type methods and properties, the equality operator may return different results on different platforms. In the .NET Compact Framework, each successive call to the Type.GetMethod method returns a new instance of System.Reflection.MethodInfo, so return values are never evaluated as equal. However, in the .NET Framework 4, calling GetMethod with the same parameters returns the same instance of MethodInfo. You must review and potentially modify your code when you are working with the following System.Reflection types: MethodInfo, FieldInfo, PropertyInfo, EventInfo, MemberInfo, MethodBase, ConstructorInfo, and ParameterInfo.

    Reflection on Open Generic Types

    On Windows Phone 7, reflection is supported on closed generic types; however, most reflection operations are not supported on open generic types. On open generic types, only the following reflection operations are supported for Windows Phone 7: Retrieving an open generic type or method by calling the GetType or GetMethods method. Creating a generic type or method from an open generic type or method by calling the MakeGenericType or MakeGenericMethod method. For all other reflection operations on open generic types, a NotSupportedException exception is thrown.

    Source: http://msdn.microsoft.com/en-us/library/gg597392.aspx

提交回复
热议问题