很容易获得.NET中所有已加载程序集的列表:
AppDomain.CurrentDomain.GetAssemblies()
但我找不到在PCL(便携式类库)代码中执行此操作的方法?有什么建议吗?
答案 0 :(得分:-2)
不确定 Deployment.Current.Parts 是否在PCL中可用,但我使用:
public static List<Assembly> GetAssemblies()
{
List<Assembly> assemblies = new List<Assembly>();
foreach (var assemblyPart in Deployment.Current.Parts)
{
StreamResourceInfo sri = Application.GetResourceStream(new Uri(assemblyPart.Source, UriKind.Relative));
Assembly a = new AssemblyPart().Load(sri.Stream);
if (a != null)
assemblies.Add(a);
}
return assemblies;
}