System.NullReferenceException occurs in xaml desig

2019-02-21 17:15发布

问题:

I've created a C++ UWP Windows 10 app using Visual Studio 2015. However, I'm not able to visualize any xaml in the designer because I'm always getting a System.NullReferenceException error. How can I fix this?

回答1:

That's very odd but I solved following these steps:

  1. Close any instance of Visual Studio
  2. Open Visual studio and create a new C# UWP empty project (name it as you like, do not matter)
  3. Run the "useless" created project then close it as Visual Studio
  4. Open again your previous C++ UWP project

In my case everything started working!



回答2:

Switching solution platform to x86 worked for me.



回答3:

I'm experiencing exactly the same problem on my primary development machine but not on another. The reason is... I think... When I installed Visual Studio 2015 on the 2nd machine, the first time I created a Universal Solution (C#) I was shown a dialog asking me to OK "elevated permissions" (custom permissions) for the VS2015 installation folder. I OK'd it and Designer works on that machine in both Blend2015 and VS2015 (community edition)

On the other machine I was never shown the dialog asking me to confirm elevated permissions and Designer does NOT work on that machine (VS2015 Enterprise). This machine also has VS2013 update 5) on it.

I am thinking that I might have to completely wipe off VS2015 and try to clean the registry of all VS2105 references AND remove the VS2015 installation directories on C:\ AND when I reinstall, create a installation directory with a different name (if I can). What a PAIN though... I'm waiting to see if MS delivers a simple solution since I'm quite positive that this whole issue boils down to a bug (feature... grrr) having to do with custom permissions that can't be changed (or added) after installation.

Would be nice is MS would confirm this... (please note, none of this involved c++... it was all C#)

Tom

this is the dialog I was shown on the machine where Designer works]1



回答4:

Installing the Windows Software Development Kit (SDK) for Windows 10 solved the issue for me. It may ask to unistall the previous version of Windows 10 RTM SDK

https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk



回答5:

This is fixed in Update 1 of Visual Studio 2015

https://www.microsoft.com/en-us/download/details.aspx?id=49989