Windows 8开发人员预览中缺少Type.GetProperty()方法

我正在尝试将一个简单的应用程序移植到Windows 8 Metro(WinRT)。 似乎缺少一些非常基本的方法。 一个基本示例: Type.GetProperty() 。 它适用于Windows Phone 7,Silverlight和.NET客户端配置文件。 我是否必须安装某些东西(例如,一个特殊的库),或者这种方法在.NET metro配置文件中根本不可用?

UPDATE

好的谢谢。 现在我使用this.GetType().GetTypeInfo().DeclaredProperties

using System.Reflection; 需要具有此GetTypeInfo()扩展方法。

地铁的反思有所改变:见MSDN (“reflection变化” – 靠近底部)。

基本上,您现在需要: type.GetTypeInfo()

除了Nicholas Butler的回复之外,我最终还是使用了这种扩展来维护代码在所有平台上的可重用性。

 #if NETFX_CORE // Workaround for .Net for Windows Store not having Type.GetProperty method public static class GetPropertyHelper { public static PropertyInfo GetProperty(this Type type, string propertyName) { return type.GetTypeInfo().GetDeclaredProperty(propertyName); } } #endif 

这样, Type.GetProperty()就可以在所有平台上实现。