5
votes
  • In VS2013: Create a Portable Class Library
  • Target .NET Framework 4.5, Windows Phone 8.1 & Windows 8
  • Write the following code:

    public class Class1
    {
        public static Type GetBaseType(Type type)
        {
            return type.BaseType;
        }
    }
    

Observe that you cannot compile: "'System.Type' does not contain a definition for 'BaseType' and no extension method 'BaseType' accepting a first argument of type 'System.Type' could be found (are you missing a using directive or an assembly reference?)"

Strange since the MSDN documentation clearly states this property should be present: http://msdn.microsoft.com/en-us/library/system.type.basetype(v=vs.110).aspx

1

1 Answers

5
votes

It is not available in WinRT apps. Properties and methods supported in WinRT have this mentioned explicitly (look at the store icon) - http://msdn.microsoft.com/en-us/library/system.type(v=vs.110).aspx

This answer provides a workaround for WinRT - What is the equivalent to Type.BaseType in WinRT?

Type.GetTypeInfo().BaseType