Print Page | Close Window

Fake Backing Store

Printed From: IdeaBlade
Category: Cocktail
Forum Name: Community Forum
Forum Discription: A professional application framework using Caliburn.Micro and DevForce
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3434
Printed Date: 20-Sep-2025 at 11:06am


Topic: Fake Backing Store
Posted By: smi-mark
Subject: Fake Backing Store
Date Posted: 09-May-2012 at 1:17pm
I've just upgraded a project to the latest cocktail and I'm having issues getting the fake backing store to work

    public class AppBootstrapper : FrameworkBootstrapper<ShellViewModel>
    {
#if FAKESTORE
        [Import]
        public IEntityManagerProvider<VITEntities> EntityManagerProvider;
 
        protected override IEnumerable<IResult> StartRuntimeAsync()
        {
            yield return EntityManagerProvider.InitializeFakeBackingStoreAsync();
        }
#endif
 
    }

InitializeFakeBackingStoreAsync() never completes. I've traced it down to FakeBackingStore.ResetCore.

I'm not getting any errors whatsoever, it just doesn't return, so the shell doesn't show. Any suggestions on what I can try?



Replies:
Posted By: mgood
Date Posted: 09-May-2012 at 3:07pm

My first instinct is your UI thread might be blocked, so the callback can't be processed.



Posted By: smi-mark
Date Posted: 09-May-2012 at 3:11pm
I'm not sure how that could be possible as this is being called from the bootstrapper, before anything else has happened.


Posted By: mgood
Date Posted: 09-May-2012 at 3:20pm
Is the above your entire bootstrapper? StartRuntimeAsync is called from StartRuntime. Are you doing anything in StartRuntime?


Posted By: smi-mark
Date Posted: 09-May-2012 at 3:22pm
That is the entire bootstrapper, copied from TempHire. I can set a breakpoint on connect and it hits ConnectAsync in ResetCore but it never hits Store.ClearAsync()

I also tested this without the fake store and it is connecting just fine.




Posted By: mgood
Date Posted: 09-May-2012 at 3:31pm
That's odd. I assume TempHire works on your machine?


Posted By: smi-mark
Date Posted: 10-May-2012 at 9:02am
Yes, it appears to work fine in TempHire (I upgraded TempHire to SL5 to make sure both are using the exact same environment)




Posted By: mgood
Date Posted: 10-May-2012 at 10:20am
How is your EnityManager being created? The latest TempHire uses an unmodified EntityManagerProvider and the out-of-the-box fake ConnectionOptions:
 
        [Export]
        public IEntityManagerProvider<TempHireEntities> TempHireEntityManagerProvider
        {
            get
            {
                var provider = new EntityManagerProvider<TempHireEntities>();
#if FAKESTORE
                provider.Configure(config => config.WithConnectionOptions(ConnectionOptions.Fake.Name));
#endif
                return provider;
            }
        }

Then on the server it injects the FakeLoginManager into the existing fake CompositionContext:
 
    public class CompositionContextResolver : ICompositionContextResolver
    {
        private static readonly CompositionContext TempHireFake = CompositionContext.Fake
            .WithGenerator(typeof(FakeLoginManager))
            .WithName(CompositionContext.Fake.Name);

        #region ICompositionContextResolver Members

        public CompositionContext GetCompositionContext(string compositionContextName)
        {
            // Overwriting the default fake composition context.           
            if (compositionContextName == CompositionContext.Fake.Name)
                return TempHireFake;

            return null;
        }

        #endregion
    }
Thanks to a bug fix in DF 6.1.7, this much simpler approach now works n-tier as well, if you just want to add a few things to an existing out-of-the-box CompositionContext.
 
What's different in your app? Perhaps the bug fix had an unintentended side effect. Are you hooking into any EM events outside of the EntityManagerDelegate?


Posted By: smi-mark
Date Posted: 10-May-2012 at 12:34pm
I'm using 6.1.6 at the moment. I ended up making a new project and all seems to work... No idea what the problem was.


Posted By: mgood
Date Posted: 10-May-2012 at 1:27pm
Cocktail 0.6 doesn't work with 6.1.6 at least not fully. The system requirements do state that you need 6.1.7. First of all the binaries are built against 6.1.7 and you'll get into conflicts eventually if you try to use them against 6.1.6. It may seem to work up to a certain point. Second, the latest Cocktail relies on bug fixes in 6.1.7.



Print Page | Close Window