locked
Silverlight MEF application doesn't work called remotely after deploy RRS feed

  • Question

  • Hi.

    My Silverlight aplication which uses MEF after deploying to WWW server and then run remotely from my browser stops working.
    (when launched from WWW serwe browser is all fine)

    Here is MEF initialization in App.xaml.cs:

    _AppAggregateCatalog = new AggregateCatalog();
    AssemblyCatalog catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
    _AppAggregateCatalog.Catalogs.Add(catalog);
    catalog = new AssemblyCatalog(typeof(THBZasoby.Common.Base.Model).Assembly);
    _AppAggregateCatalog.Catalogs.Add(catalog);     
    (..)
    CompositionContainer container = new CompositionContainer(_AppAggregateCatalog);
    CompositionHost.Initialize(container);

    All pointed assemblies are in the same main XAP.

    Then here is how looks my ViewModelLocator:

    public class ViewModelLocator
        {       
            public ViewModelLocator()
            {
                CompositionInitializer.SatisfyImports(this);
            }                       

            public BranchDetailsVM BranchDetails
            {
                get
                {
                    return _BranchDetails.Value;
                }
            }
            [Import(RequiredCreationPolicy = CreationPolicy.NonShared)]
            private Lazy<BranchDetailsVM> _BranchDetails { get; set; }

    (..)

    Here one of view models:
    [Export]
    public class BranchDetailsVM : PageViewModelBase
    {
            [ImportingConstructor]
            public BranchDetailsVM(IMessagesService messagesService, IBranchService dataService)
            {
                _MessagesService = messagesService;
                _DataService = dataService;
            } (..)

    I could resolve few first exceptions by changing private imported by MEF fields into public properties (don't know why this helper but did..). But this approach doesnt work on Lazy properties in ViewModelLocator, locator doesn't return to views any view models.

    Adding
    <runtime>
      <loadFromRemoteSources enabled="true"/>
    </runtime>
    to web.config didn't help (added it also to app.config in main SL project)

    Any tip why working applicetion after deploy behaves so poorly ?

    Cheras, Rafal.

     

    Wednesday, June 27, 2012 2:24 PM

Answers

  • Problem resolved - just in PageViewModel i still had private filds imported by MEF - had to change them into public imports ..
    • Marked as answer by Rafal.R Thursday, June 28, 2012 9:38 AM
    Thursday, June 28, 2012 9:38 AM