Silverlight MEF application doesn't work called remotely after deploy

Verrouillé Silverlight MEF application doesn't work called remotely after deploy

  • mercredi 27 juin 2012 14:24
     
     

    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.

     

Toutes les réponses

  • jeudi 28 juin 2012 09:38
     
     Traitée
    Problem resolved - just in PageViewModel i still had private filds imported by MEF - had to change them into public imports ..
    • Marqué comme réponse Rafal.R jeudi 28 juin 2012 09:38
    •