I want to inspect assemblies if they have a specific type without loading the assembly in the current scope, which is available via MetadataLoadContext in .NET Core 3.

But if I try the following example

internal static class Program {
        // ReSharper disable once UnusedParameter.Local
        private static void Main(string[] args) {

            var paths = new string[] {@"Plugin.dll"};
            var resolver = new PathAssemblyResolver(paths);
            var pluginInterface = typeof(IPlugin);
            using (var context = new MetadataLoadContext(resolver)) {
                var assembly =
                foreach (var type in assembly.GetTypes()) {
                    if (type.IsClass && pluginInterface.IsAssignableFrom(type))


I get an exception "System.IO.FileNotFoundException: Could not find core assembly. Either specify a valid core assembly name in the MetadataLoadContext constructor or provide a MetadataAssemblyResolver that can load the core assembly."

at var context = new MetadataLoadContext(resolver)

What is meant by core assembly ? Or what I am doing wrong ? https://blog.vincentbitter.nl/net-core-3-0/ seems not working for me.

Related posts

Recent Viewed