5

I'm developing a UWP app with Visual Studio 2015, and one of the things I want to do use some sample data at design time.

Now, I've added a XAML file, set the build action as DesignDataWithDesignTimeCrateableTypes

My XAML is really straight forward here:

<local:Freead
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"       
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:MyNamespace.Uwp.Windows.ViewModels" 
    xmlns:ad="clr-namespace:MyNamespace.Classifieds;assembly=LocalAngle.Uwp" 
    ItemName="Java books" 
    Description="Free to anyone that wants them. A little out of date, but would make a handy doorstop." 
    ContactDetails="01632 960000" 
    Latitude="52.22" Longitude="1.95">
</local:Freead>

However, the intellisense is giving me pale blue wavy line and a tooltip for that of:

Cannot create instance of "Freead".

Historically, I've been able to debug the XAML design issues by firing up another instance of Visual Studio, attaching, and setting to break on all exceptions, but no exceptions appear to be thrown here, so how can I debug why it cannot create an instance of the type? (Given the obvious has already been checked, i.e. there is a parameterless constructor, and solution does build)

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166

1 Answers1

8

I was having XAML Designer errors and tried the old pre-Visual Studio 2015 approach:

  • Close any open XAML Designer windows
  • Start up another VS 2015 instance
  • Attach to the "XDesProc.exe" process (for me there was only one)
  • Open the problematic XAML page in the designer in the original VS instance

My error was "Object not initialized", but it was quite quick to find the underlying problem. Fixing it was a bit more effort!

Jack
  • 871
  • 1
  • 9
  • 17
JohnBob
  • 81
  • 1
  • I never remember this and I attach to devenv.exe :\ Thanks! – Ignacio Soler Garcia Feb 08 '18 at 11:50
  • 2
    When targeting Windows build 16299 or above, the process to attach to is different. You'll need to look for `UwpSurface.exe` for UWP projects and `WpfSurface.exe` for WPF projects. The entire process for debugging can be found here (there is a dropdown in the top left to select different versions of Visual Studio): https://learn.microsoft.com/en-us/visualstudio/xaml-tools/debugging-or-disabling-project-code-in-xaml-designer – mark.monteiro Aug 24 '21 at 14:45