1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| # .NET Framework 版本 var extAss = Assembly.Load("MultiToolKit.WpfApp.Modules.Home"); var catalog = new AssemblyCatalog(extAss); var container = new CompositionContainer(catalog);
var extWindowsList = container.GetExportedValue<IEnumerable<ExportFactory<Window, IDictionary<string, object>>>>( "extWindows");
# .NET 版本 var executableLocation = Assembly.GetEntryAssembly().Location; var path = Path.GetDirectoryName(executableLocation); var assemblies = Directory .GetFiles(path, "*.dll", SearchOption.AllDirectories) .Select(AssemblyLoadContext.Default.LoadFromAssemblyPath) .ToList(); var configuration = new ContainerConfiguration() .WithAssemblies(assemblies); using var container = configuration.CreateContainer(); _extWindowsList = container.GetExports<ExportFactory<Window, IDictionary<string, object>>>();
|