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

不想你离开。 提交于 2019-12-05 10:07:32

问题


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.



来源:https://stackoverflow.com/questions/31987252/how-to-get-assembly-from-a-type-object-in-uwp-aka-net-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!