Last active
August 14, 2016 21:57
-
-
Save jcansdale/f0c2f70c2dc8094e4fb8eaba6506a550 to your computer and use it in GitHub Desktop.
.NET Core implementation of AppDomain.GetAssemblies()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Assembly[] GetAssemblies() | |
{ | |
var assemblies = new List<Assembly>(); | |
foreach(ProcessModule module in Process.GetCurrentProcess().Modules) | |
{ | |
try | |
{ | |
var assemblyName = AssemblyLoadContext.GetAssemblyName(module.FileName); | |
var assembly = Assembly.Load(assemblyName); | |
assemblies.Add(assembly); | |
} | |
catch(BadImageFormatException) | |
{ | |
// ignore native modules | |
} | |
} | |
return assemblies.ToArray(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment