I am using MEF to create "plugins" for my WPF application. Some of these plugins I want to embed directly into the EXE file as the EXE needs to be standalone. I am using Costura by Fody to embed the resource along with all my other references. As the exe file needs to be standalone I am unable to create a directory for these plugins and use the DirectoyCatalog
Is there anyway I can either load the assembly from the embedded resource, or simply specify the assembly name such as:
catalog.Catalogs.Add(new AssemblyCatalog("My.Assembly.Name));
I have tried looping through the Manifest resources but these appear to be zipped by Fody:
var resourceNames = GetType().Assembly.GetManifestResourceNames();
foreach (var resourceName in resourceNames)
Any help/suggestions appreciated.
I was able to get this to work in my project simply by loading the assemblies from the current AppDomain.
Ok so got this to work for me, using the class below (found this code at https://github.com/Sebazzz/EntityProfiler/blob/master/src/UI/EntityProfiler.Viewer/AppBootstrapper.cs and tweaked to suit my needs):
To use it you simply call the extract function which will find any Costura Zip files in resource manifest and decompresses it and registers it.
The function returns a dictionary of all assemblies that match the string passed in the function. I then iterate over them and add to catalog to be used by composition container:
Class: