Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Assembly from a Type object in UWP (aka .NET Core)

Tags:

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.

like image 611
szt69 Avatar asked Aug 13 '15 11:08

szt69


2 Answers

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

like image 66
blackheart Avatar answered Sep 20 '22 15:09

blackheart


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

like image 31
szt69 Avatar answered Sep 22 '22 15:09

szt69