Universal App Gotchas : NullReferenceException in Blend Opening Views from Visual Studio with MVVM Light

TL;DR: open the whole solution in blend*.

*for my scenario.

On using the Open In Blend menu option from right clicking a view in Visual Studio…

OpenInBlend
Open In BlendBlendNullReferenceException.png

…I was experiencing the following System.NullReferenceException when opening the view in the Designer…

BlendNullReferenceException.png
System.NullReferenceException

…on further investigation “The Resource “Locator” Could not be resolved.”

Explanation

When you right click Open in Blend, it will open the project that your view resides in, along with the View itself in the design window. What it won’t do however, is bring with it any resources it requires from other projects at design time. In this case, my App.xaml file located within the .Shared project, and NOT the platform specific project being loaded was defining my static resources and as such it could not be resolved due to not currently being loaded in Expression Blend. As mentioned in a previous post, the shared folder for all intents and purposes is part of the platform specific projects at compile time.

 Resolution

My resolution was simple, open the entire Solution in Blend allowing it to be resolved!

Seems obvious now but I was stumped for a little while there! Hopefully this will come in handy to someone.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s