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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:42:32+00:00 2026-05-23T18:42:32+00:00

I am trying to use MEF to do this, but maybe I am using

  • 0

I am trying to use MEF to do this, but maybe I am using the wrong technology.

I have 2 applications(both are more ideas right now) One is a desktop application that I am converting to Silverlight. The other is just an idea that fits into the same structure. I want to take both applications as individual self contained applications and run them from within a shell site. I have been trying to start this with MEF, but I dont know enough about it yet in order to know whether I am doing something wrong, or its not the right technology.

Currently I am using MVVM-light as my framework, I have had great success with this and am pretty familiar with it by now. Each of my applications are selfcontained…meaning that I can use them by themself If i set them to run from my webserver standalone.

The problem comes when I try to get them into my shell using mef.

This is the code for my first modulecontainer:

public partial class MEFDoctorsModuleContainer : Page, IPartImportsSatisfiedNotification
    {
        private System.Uri _requestedUri;

        public MEFDoctorsModuleContainer()
        {
            InitializeComponent();

        }

        [Import]
        public IDeploymentCatalogService CatalogService { get; set; }

        [ImportMany(AllowRecomposition = true)]
        public Lazy<UserControl, IMetadataContent>[] MEFModuleList { get; set; }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            _requestedUri = e.Uri;

            CompositionInitializer.SatisfyImports(this);
        }


        public void OnImportsSatisfied()
        {
            CatalogService.AddXap("WavelengthIS.Referee.PhysicianMaster.xap");

            //MEFModuleList.ToList()
            //       .ForEach(module =>
            //       {
            //           if ((module.Metadata.ContainerType == this.GetType().ToString() &&
            //               (module.Value.GetType().ToString() == "WavelengthIS.Referee.PhysicianMaster.MainPage.xaml")))
            //           {
            //               content.Items.Add(module.Value);
            //           }
            //       });

            MEFModuleList.ToList()
                  .ForEach(delegate(Lazy<UserControl, IMetadataContent> module)
                           {
                               if ((module.Metadata.ContainerType == this.GetType().ToString() && (module.Value.GetType().ToString() == "WavelengthIS.Referee.PhysicianMaster.App.xaml")))
                                   content.Items.Add(module.Value);
                           });
        }
    }
}

Right now the xap consists of only one Project, but eventually it will consist of my Data,ViewModel, and service projects for the client. But even then it crashes. It doesnst seem to like the viewmodellocator.

(module.Value.GetType().ToString() == "WavelengthIS.Referee.PhysicianMaster.App.xaml")))

used to equal this

(module.Value.GetType().ToString() == "WavelengthIS.Referee.PhysicianMaster.MainPage.xaml")))

But I was thinking that this wouldnt work, because I am actually importing an application and not just a page.

so my question is this: Given what I am trying to do what are my best options to make this work?

I am not stuck on MEF, But I do require a Shell application that loads the standalones into it using a navigation framework that is in SL4. I require that MVVM-Light works because I like that framework alot and even though i have written MVVM Enterprise apps without it, I prefer to have it in my bag of tricks. I dont like hocus pocus…IOC and Dependency Injection are off the table because I am not comfortable using that technology yet and If I need to use it Ill find some other way to do this.

  • 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-23T18:42:33+00:00Added an answer on May 23, 2026 at 6:42 pm

    Try having the ViewModelLocator being dynamic, like in this post: http://rickrat.wordpress.com/2011/01/24/using-mef-to-link-view-model-locator-and-load-assembly-uis-dynamically/

    It works for me in WPF, should in SL4 too. MEF is the right way to go with this. I’ve done practically the same thing in WPF time and again, with MEF and MVVM light. No hocus-pocus here either… 🙂

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

Sidebar

Related Questions

I'm trying to use MEF in an assembly that builds against both .NET 4.0
I am trying use MySql and Entity Framework, using Connector/Net 6.1 with this as
I'm trying to use MEF in my asp.net mvc 3 application, but I could
I am trying use Thread but i have some problem (I am beginner at
Im trying use a Java annotation in a Groovy class but have trouble to
Trying to use a guid as a resource id in a rest url but
Trying to use this method (gist of which is use self.method_name in the FunnyHelper
Trying to use this code to connect the AD PrincipalContext context = new PrincipalContext(ContextType.Domain,
I am trying to use MEF to Export the following: [Export(typeof(IRepository<>))] public class Repository<T>
I have been trying use the edit_post_link() function to contain an image. All of

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.