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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:18:41+00:00 2026-05-28T04:18:41+00:00

Importing parts in MEF is easy. [ImportMany(typeof(IModule))] public List<IModule> Modules {get; set;} But the

  • 0

Importing parts in MEF is easy.

[ImportMany(typeof(IModule))]
public List<IModule> Modules {get; set;}

But the shell application needs to be able to provide some services to the parts.

For example the shell application has access to the datalayer, knows about authentication and authorization, etc…

Is there a simple solution. (perhaps this is really a no-brainer?) Any best practices?

  • 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-28T04:18:42+00:00Added an answer on May 28, 2026 at 4:18 am

    Why not export these services?

    [Export(typeof(IMyService))]
    public class MyService : IMyService
    {
        ...
    }
    

    If the service is bound to the shell and the shell is in charge of configuring it, then you can export it as a shell property; in which case you need to remove the export attribute from the MyService class and have this:

    public class Shell : Window
    {
        [Export]
        public IMyService MyService
        {
            get
            {
                MyService service = new MyService();
    
                // initialize service
    
                return service;
            }
        }
    }
    

    Then each part can import and use them.

    [ModuleExport(typeof(MyModule))]
    public class MyModule : IModule
    {
        [Import]
        public IMyService MyService { get; set; }
    }
    

    This way you know the service is configured by the shell when it’s imported.

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

Sidebar

Related Questions

I am trying to get the PowerBuilder 10.5.2 sample web services application running. I
i'm importing several parts of a Databasedump in text Format into MySQL, the problem
Hi I user WPF/Calibur Micro/MEF. I I try have more active screen in shell.
I have a WPF application which is tiled into multiple parts as you can
I am refactoring a part of our legacy app which handles exporting and importing
Importing a Maven project into Eclipse has brought up the error: Plugin execution not
While importing website through content porter, I am getting an error that names and
After importing content from a legacy website using the Feeds module, I'm left with
When importing or exporting Databases using Taps in heroku , is it necessary that
I'm importing shapefiles into a Postgres+PostGIS database. Here's my usual procedure: * Find an

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.