MEF load plugin from directory

.net-assembly, c#, location, mef

Solution

Hello again and thanks for your response, so my problem was to load the plugin directly, so i create a directory and i place my plugins in this folder, so i find this solution

public void AssembleCalculatorComponents()
        {


            string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins");
            Console.WriteLine(path);
            //Check the directory exists
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            Console.WriteLine(path);
            string assemblyName = Assembly.GetEntryAssembly().FullName;
            Console.WriteLine(assemblyName);
            //Create an assembly catalog of the assemblies with exports
            var catalog = new AggregateCatalog(
                new AssemblyCatalog(Assembly.GetExecutingAssembly().Location),
                new AssemblyCatalog(Assembly.Load(assemblyName)),
                new DirectoryCatalog(path, "*.dll"));

            //Create a composition container
            var container = new CompositionContainer(catalog);
            container.ComposeParts(this);

this is my solution , thinks for all

Problem

I work with MEF and I am looking how to change the url of the location of plugins by another means that MEF find the plugins, I want to change this line ``` Assembly.LoadFrom(@"C:\julia\project\project.Plugin.Nav\bin\Debug\NavPlugin.dll"))); ``` I want to delete this url because I need to deploy my application in another machine This is my function : ``` public void AssembleCalculatorComponents() { try { //var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly()); //var container = new CompositionContainer(catalog); //container.ComposeParts(this); var catalog = new AggregateCatalog(); catalog.Catalogs.Add(new AssemblyCatalog(Assembly.LoadFrom(@"C:\yosra\project\project.Plugin.Nav\bin\Debug\NavPlugin.dll"))); var container = new CompositionContainer(catalog); container.ComposeParts(this); } catch (Exception ex) { throw ex; } } ``` Can you please help me? Thanks

Original source