Metro Style Appポータブルライブラリのクラスのカスタム属性を定義および取得しようとしています。メトロスタイルAppのカスタムクラス属性
[AttributeUsage(AttributeTargets.Class)]
public class FooAttribute : Attribute
{
}
[Foo]
public class Bar
{
}
class Program
{
static void Main(string[] args)
{
var attrs = CustomAttributeExtensions.GetCustomAttribute<FooAttribute>(typeof(Bar));
}
}
ような何かOPによると
Cannot convert type 'System.Type' to 'System.Reflection.MemberInfo'
おかげ
どうやら、あなたは( VAR attrsに= CustomAttributeExtensions.GetCustomAttributeを行う必要がありますtypeof(Bar).GetTypeInfo()); –
http://msdn.microsoft.com/en-us/library/windows/apps/hh535795%28v=vs.110%29.aspx –
@ user1364325上記のコメントのコードが問題を解決する場合は、答えとそれに答えてマークしてください。 – Adam