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

  • Home
  • SEARCH
  • 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 7367939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:36:03+00:00 2026-05-29T03:36:03+00:00

I have a problem when retrieving information from an imported attribute. The attribute remains

  • 0

I have a problem when retrieving information from an imported attribute. The attribute remains null after calling .ComposeParts(), but the composition is OK, because I can call .GetExportedValues() afterwards and I get the needed instance. Here is the code:

Bootstrapper doing the composition

 [Export]
public class Bootstrapper
{
    public void Run()
    {
        doComposition();
    }

    private void doComposition()
    {
        var catalog = new AggregateCatalog();

        catalog.Catalogs.Add(new DirectoryCatalog("./Applications"));
        catalog.Catalogs.Add(new AssemblyCatalog(typeof(Loader).Assembly));

        Container = new CompositionContainer(catalog);
        // Apps = Container.GetExportedValues<IApplication>(); - this gets me the IApplication(s), but I dont understand why Apps isn't injected automatically
        Container.ComposeParts(catalog);
        IEnumerable<IApplication> app = Container.GetExportedValues<IApplication>();
    }

    public CompositionContainer Container { get; set; }

    private IEnumerable<IApplication> apps;

    [ImportMany(typeof(IApplication))]
    public IEnumerable<IApplication> Apps
    {
        get { return apps; }
        set
        {
            apps = value;
        }
    }

Signature of one of the classes implementing IApplication

[Export(typeof(IApplication))]
public class MDFApplication : IApplication {...}

Any pointers are appreciated, thanks a lot.

  • 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-29T03:36:04+00:00Added an answer on May 29, 2026 at 3:36 am

    You never call any code to compose your Bootstrapper class. ComposeParts will create the catalog, it will not create or compose any classes until you specifically ask for them.

    The container doesn’t search for all members that require an import when you call GetExportedValues. It either returns an already existing instance or it creates a new one, satisfying all its import attributes.

    In other words, the following code will return a fully constructed Bootstraper class:

            var b= Container.GetExportedValue<Bootstrapper>();
            Debug.Assert(b.Apps!=null);            
    

    In order to compose an object that already exists, you need to call the SatisfyImportsOnce method. This will find all imports and satisfy them if possible. E.g.

            Container.SatisfyImportsOnce(this);
            Debug.Assert(this.Apps != null);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with retrieving information from a XML tree. My XML has
So I managed to solve a problem of retrieving information from the bundle, but
We have a problem with the Euro character when saving and retrieving it from
I have a problem retrieving default values from the settings bundle when first launching
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have several laptops in the field that need to daily get information from
I have created a DLL that will gather information from the AssemblyInfo.cs. In the
I'm retrieving information about resources from a MySQL database using PHP. The information about
heres the problem, i have a database thats hold information on marker images: i'm
I am supervising a project done by two students that involves retrieving information from

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.