How to get Assembly from a Type object in UWP (aka

2019-04-18 20:08发布

问题:

The Type class has got an Assembly attribute in .NET Framework. However this attribute is gone when you are writing an UWP which is of course using .NET Core. Only the AssemblyQualifiedName attribute is available.

How can I get to the Assembly from this name?

Please bear in mind that lot of the usual classes are not available in .NET Core, so your usual .NET Framework answer might not work. E.g. there is no such thing as AppDomain, etc.

回答1:

You can use typeof(xxx).GetTypeInfo().Assembly to get Assembly。



回答2:

Ok I have overlooked the TypeInfo class that is available using GetTypeInfo on a Type object. TypeInfo has got the Assembly property.