.BaseType type in portable class library

  • In VS2013: creating a portable class library
  • Target .NET Framework 4.5, Windows Phone 8.1, and Windows 8
  • Write the following code:

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

Note that you cannot compile: "System.Type" does not contain a definition for "BaseType", and no extension method "BaseType" that accepts the first argument of type "System.Type" was found (you are missing using the directive or link to assembly?) "

It is strange because the MSDN documentation clearly states that this property must be present: http://msdn.microsoft.com/en-us/library/system.type.basetype(v=vs.110).aspx

+5
source share
1 answer

It is not available in WinRT applications. The properties and methods supported in WinRT mentioned it 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 equivalent to the Type.BaseType type in WinRT?

 Type.GetTypeInfo().BaseType 
+4
source

Source: https://habr.com/ru/post/1200544/


All Articles