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 1046143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:05:54+00:00 2026-05-16T16:05:54+00:00

I’ve been trying to figure this for a few days now, with no luck.

  • 0

I’ve been trying to figure this for a few days now, with no luck.

I’m trying to use the [ImportMany] to import from a directory full of DLL’s with exports of type IEditorSystem, that have custom metadate of type IEditorSystemMetadata. I’d like to get the metadata first, and push it out to some textboxs etc so the user can choose which EditorSystem to use, and when selected, load that system…

I’ve been following examples as best as I can, here’s what I have so far.

[ImportMany]
public ObservableCollection<Lazy<IEditorSystem, IEditorSystemMetadata>> EditorSystemList

This is what it should be importing:

[Export(typeof(IEditorSystem))]
    [SignalSystemData("Very Very Long Name", "Short Name")]
    public class MyEditorSystem: IEditorSystem
    {
        public MyEditorSystem()
        {
        }
    }

and the startup:

AggregateCatalog Catalog = new AggregateCatalog(
                new DirectoryCatalog(@".\EditorSystems"),
                new AssemblyCatalog(Assembly.GetExecutingAssembly()));
            CompositionContainer Container = new CompositionContainer(Catalog);
            Container.ComposeParts(this);

I can see in the Catalog.Parts both the MyEditorSystem and the viewmodel that has the ImportMany, but EditorSystemList never gets populated. I get no Composition errors.

I thought it might have something to do with the Lazy<>, so i tried

public ObservableCollection<IEditorSystem> EditorSystemList

No luck either.

The only complication I can think of is that I’m using Cinch, which uses MEFedMVVM, which also uses MEF. I don’t think it interferes, but I’m not really sure.

I figure I’m doing it wrong, can anyone make sense of this?

Update:

Implement a new IComposer, with exactly the catalog you need.

ImportMany is still failing though, but only when I try to import metadata with it. The metadata is just a couple of strings, and as far as I am able to determine, follows the examples.

FINALLY found the cause: The implementations of IEditorSystem are in a seperate DLL, as noted before.
However, any new builds of the dll are not copied to the output subdir of the main project.
I had copied the first one manually, and forgot to add a post-build copy to the dll project.
Oh well, learned a bunch of stuff about MEF, so not completely wasted days 🙂

  • 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-16T16:05:55+00:00Added an answer on May 16, 2026 at 4:05 pm

    Without seeing your code, I believe all you need to change is

    public ObservableCollection<Lazy<IEditorSystem, IEditorSystemMetadata>> EditorSystemList  
    

    should be

    public IEnumerable<Lazy<IEditorSystem, IEditorSystemMetadata>> EditorSystemList;
    

    Here is a sample:

    class Program
    {
        static void Main(string[] args)
        {
            var c = new Class1();
            var v = c.EditorSystemList;
            foreach (var lazy in v)
            {
                if (lazy.Metadata.LongName == "Very Very Long Name")
                {
                    var v2 = lazy.Value;
                    // v2 is the instance of MyEditorSystem
                }
            }
        }
    }
    
    public class Class1
    {
        [ImportMany]
        public IEnumerable<Lazy<IEditorSystem, IEditorSystemMetadata>> EditorSystemList;
    
        public Class1()
        {
            var catalog = new AggregateCatalog(
                new AssemblyCatalog(Assembly.GetExecutingAssembly()));
            var container = new CompositionContainer(catalog);
            container.ComposeParts(this);
        }
    }
    
    [Export(typeof(IEditorSystem))]
    [SignalSystemData("Very Very Long Name", "Short Name")]
    public class MyEditorSystem : IEditorSystem { }
    
    public interface IEditorSystem { }
    
    [MetadataAttribute]
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
    public class SignalSystemDataAttribute : ExportAttribute
    {
        public SignalSystemDataAttribute(string longName, string shortName)
            : base(typeof(IEditorSystem))
        {
            LongName = longName;
            ShortName = shortName;
        }
        public string LongName { get; set; }
        public string ShortName { get; set; }
    }
    
    public interface IEditorSystemMetadata
    {
        string LongName { get; }
        string ShortName { get; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.