ViewAwareStatus Bug in change set 50505

Sep 7, 2010 at 5:19 PM
Edited Sep 7, 2010 at 6:31 PM

Hi Sacha,

Since I've upgrade from change set 48912 to 50505 design-time support seems to be broken, even on your demo project. After some debugging I found that during design-time ViewAwareStatus::InjectContext() that view is always null.

So the following always is false:

 

            var x = view as FrameworkElement;

            if (x != null)
            {
                x.Loaded += OnViewLoaded;
                x.Unloaded += OnViewUnloaded;

                Window w = x as Window;
                if (w != null)
                {
                    w.Activated += OnViewActivated;
                    w.Deactivated += OnViewDeactivated;
                }

                //get the Views Dispatcher
                this.ViewsDispatcher = x.Dispatcher;
                weakViewInstance = new WeakReference(x);

            }

 

When debugging design time using change set 48912 then x != null, with change set 50505 then x == null

You can easily reproduce this using the CinchV2 WPF demo, open it in Blend, attached VS debugger to Blend, put breakpoint in ViewAwareStatus and open ImageLoaderView in Blend.

Any idea where I should look to fix this?

Beyers

Coordinator
Sep 8, 2010 at 7:35 AM

100% worked for me at home, and you are 1st person out of 700 odd people to mention this, I will try it at work, and let you know what I find out.

Coordinator
Sep 8, 2010 at 8:30 AM

Yeah I can repeat that at work, strange, did not happen at home, I will talk to Marlon, as its more his area than Cinch.

Sep 8, 2010 at 8:54 AM

Thank you Sacha.

Coordinator
Sep 8, 2010 at 9:54 AM

we are both looking into it. Let you know when its done

Coordinator
Sep 8, 2010 at 2:37 PM

This is a weird one for sure. I have tried debugging both mine and Marlons code all looks fine, but does not work in design time at all. Works fine at runtime. It does work using release 50505 code for me at home, and on laptop also. I then took older version of meffed and used that with release 50505 of Cinch and that worked just fine. For example using Meffed release 55859, with CInch 50505 works just fine.

 

I will maybe try and grab Uber latest Meffed and try again

Coordinator
Sep 8, 2010 at 7:39 PM

Checked at home and I do have same issues actually which is really weird as I swore I checked before I uploaded, and all was good.. Fix for now is use Meffed 55859 that works fine, and does all you need, Marlon has just added a few bits after that, but they are not important to CinchV2 operation.

 

I think I will have to include the MEF version I need soon, as if Marlon makes breaking changes I do not want Cinch users affected

Sep 8, 2010 at 11:39 PM

Sacha, I found the exact line giving the issues. The following change introduced the issue: http://mefedmvvm.codeplex.com/SourceControl/diff/file/view/58315?fileId=1525683

So in MEFedMVVMDemo/MEFedMVVM/ViewModelLocator/BasicViewModelInializer.cs changing line 35:

from:

var vm = viewModelContext.Value;

to:

var vm = resolver.GetExportedValue(viewModelContext);

solves the issue for me. I tested the above with latest Meffed 60539 and it works fine. Unfortunately I dont know Meffed inners at all, so I have no idea what Marlon's motivation was for changing this line in the first place, maybe you can check with him?

 

Beyers

Coordinator
Sep 9, 2010 at 6:32 AM

Excellent work Beyers, I'll check with him.

Coordinator
Sep 9, 2010 at 6:46 AM

Beyers have sent a email to Marlon on this, just a waiting game now.

Coordinator
Sep 9, 2010 at 7:36 AM

Beyers

 

Marlon has now fixed this, I will resync with MefedMVVM latest release at weekend, and fix one tiny bug. Thanks for all your help

Sep 9, 2010 at 10:07 AM

Great stuff, thanks Sacha.

Coordinator
Sep 9, 2010 at 3:29 PM

Should find time this weekend.

Coordinator
Sep 11, 2010 at 6:03 AM

All fixed and checked in right now, thanks so much for your help with this one. Marlon was impressed you nailed the exact line that caused the problem, he was most apologetic. And something good has come out of it actually, everytime he does a new release of MefedMVVM he will tell me and I will make sure it works with CInchV2. Stupid really we should have done this before, but I do not like to just bang out a new release every few days, I would be annoyed by that myself. Still better to have reliable framework I think, so had to release for this as it was broken. As I say thanks man, all fixed verified and checked in now.