And*_*rey 9 .net c# portable-class-library
在.NET中很容易获得所有已加载程序集的列表:
AppDomain.CurrentDomain.GetAssemblies()
Run Code Online (Sandbox Code Playgroud)
但我找不到在PCL(可移植类库)代码中执行此操作的方法?有什么建议?
Mus*_*ion -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;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1360 次 |
| 最近记录: |