Passing an Oject from main module to the others

Topics: Bootstrappers & IoC
Jan 19, 2012 at 11:23 AM


I've stared splitting my WPF code into smaller modules... I've got a problem about an object wich contains some specific value as userID,roles and so on...  is there a way of exporting that object somewhere and get it via IoC?

I've tried doing so


 protected override void InitializeCompositionBatch(CompositionBatch batch)

            var catalog = new AggregateCatalog(AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>());
            container = new CompositionContainer(catalog);

            var provider = new EntityManagerProvider();




            batch.AddExportedValue(App.LoggedUser); //here it's still null, I set it after a LoginViewModel's action


and getting it via IoC


    public class myViewModel : Screen
        MyUser _myUser;

        public TitoliDepositatiViewModel(IApplicationRepository repository,MyUser myUser)
            : base(repository)
           _myUser= myUser;
            base.DisplayName = ExtendedDescription;
            //Date = App.DataLavorativa;
            Date = DateTime.Now.Date;


but it's still null...what am I doing wrong?


Jan 19, 2012 at 1:29 PM
Edited Jan 19, 2012 at 1:30 PM

I recommend creating an different object which has a User property so that you can register it at the beginning with AddExportedValue. Then you can just change the User property in your login view model.

Jan 19, 2012 at 1:33 PM

Hello EisenbergEffect,

for now I've fixed using the Manager.Principal that reflect 100% the MyUser class, btw if I'll need to pass items across project I'll so so,