Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 227923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:38:21+00:00 2026-05-11T19:38:21+00:00

i am currently working with MEF and facing some problems what i want is

  • 0

i am currently working with MEF and facing some problems

what i want is to load dlls from the directory.

first i scan the directory and save two things in dictionary

Name property from respective DLL (as string)

and Module Name (as string)

here is ScanDirectory() code

private void ScanPluginDirectory()
{
    catalog = new AggregateCatalog();

    catalog.Catalogs.Add(new DirectoryCatalog(@"..\..\plugin"));            
    container = new CompositionContainer(catalog);

    batch = new CompositionBatch();
    batch.AddPart(this);        

    container.Compose(batch);    

    pluginDictionary = new Dictionary<String, String>();
    foreach (IFilter filter in filters)
    {
        Type t = filter.GetType();
        pluginDictionary.Add(filter.Name, t.Module.Name);
    }
}

and show their name in a checkbox list. upon selection of dll from checkbox.

i have import statement as

[Import]
public IEnumerable<IFilter> filters { get; set; }

currently my program is running fine. what i did is when i check a plugin from checkbox list. it moves it into “loaded” directory and and they QueryPlugin() method looks into “loaded” directory to search for plugins.

upon unchecking plugin from checkbox list. i move it out of “loaded” directory…

What i want is to use batch.RemovePart() method to get rid of this rapid moving of dlls from one directory to other….

NOTE: i am not adding plugins manually into batch using

batch.AddPart(new DemoFilter1());

instead of this i used DirectoryCatalog();;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:38:21+00:00Added an answer on May 11, 2026 at 7:38 pm

    Instead of using a DirectoryCatalog, use an AggregateCatalog and add an AssemblyCatalog for each assembly in the directory to the aggregate catalog. Then when a plugin is checked or unchecked, you can add or remove the corresponding AssemblyCatalog to the AggregateCatalog.

    Note that there may be problems with this approach if there is more than one plugin in a given assembly. A more robust approach could be filtering individual part definitions using a filtered catalog.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently working with PictureBox and facing one problem. First, I have drawn one
The system I am currently working on requires some role-based security, which is well
Currently working on a VBScript to automate some of the dirty PST ingestion work
Im currently working on a project for my first course in Ruby. A part
I'm currently working on a Flash application that needs to save files to Drupal.
Were currently working on a script that reads the current users information from out
im currently working on a classification task using language modelling. The first part of
Im currently working on creating some appwidgets for my application; one of those is
I currently working on a application that use Entity Framework 4.1 (code first) and
I currently working on an issue tracker for my company to help them keep

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.