Stopbyte

How can i fix Visual Studio 2015 WPF/XAML Designer Loading Issues?

I am making a small software application using WPFMicrosoft” technology, on Visual Studio 2015. But at some point the designer started crushing over and over again, before not being to load window Designer at all.

I don’t use any 3rd Party UI elements only simple Windows with some User Controls within it.


Edit:
Here is a snippet from my Window XAML code:

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:helpers="clr-namespace:Prj1r.Helpers"
        xmlns:model="clr-namespace:Prj1r.Model"
    xmlns:cols="clr-namespace:System.Collections;assembly=mscorlib"
        xmlns:System="clr-namespace:System;assembly=mscorlib" x:Name="window" x:Class="Prj1r.Presentations.Window1"
        Height="600" Width="600" WindowStartupLocation="CenterScreen" 
        WindowStyle="None" ShowInTaskbar="False" AllowsTransparency="True" Background="Transparent"
        Loaded="Window_Loaded_1">
    <Window.Resources>
        <helpers:PXStringConverter x:Key="PlayerSalaryStringConverter"/>
        <helpers:PxSelectionConverter x:Key="PlayerSelectionConverter"/>
        <helpers:MDateConverter x:Key="PlayerDateConverter"/>
        <helpers:FirstNameConverter x:Key="FirstNameConverter"/>
        <helpers:SalaryColorConverter x:Key="PlayerSalaryColorConverter" />
    </Window.Resources>
    <Window.DataContext>
        <Binding Path="SelectedUser" Source="{StaticResource Locator}"/>
    </Window.DataContext>
 
    <!-- Window Content: Even after removing all content it still wont load. -->
 </Window>
1 Like

I noticed that your window without any content still crushes the WPF designer, So i think you should check your Converters for these criteria:

  • They should handle the null values and Parameters before using them.
  • Should check Value and Parameter types before using them, use operators such as (is, typeof()…etc).
  • Doesn’t return any data types unexpected by the XAML code.
  • And finally make sure that your converter never through Exceptions, as WPF never knows how to handle them for you, plus it’s bad practice in terms of performance.
2 Likes

@sparta @afree: That must be the exact reason for sure, usually programmers miss the null or data type checkup on converters.

Here is a better way to find the exact source of the problem instead of the guessing method @sparta offered:

  • Close all open documents on your Visual Studio Workspace.

  • Go to Task Manager and Terminate the XDesProc.exe process.

  • Open an XAML Window file in the designer preferably someone that renders without Errors; this will allow to restart the XDesProc.exe process, check your Task manager to see if that process has started again or not, if not try to open a different XAML Document designer.

  • Now Start a new Visual Studio 2015 Instance without the need to Load any solution or project.

  • Click the Attach to Button or Debug > Attach to Process…

  • That should open a dialog where you select to which process you want to attach the Visual Studio debugger. Find the XDesProc.exe process and click attach.

  • Now what we did here, is that we are Debugging The First Instance Of Visual Studio with the Second instance, that will allow us to see all Exceptions, Errors…etc that happen in the First Instance of Visual Studio at Runtime including the Designer Exception that prevents it from rendering your document.

  • Now you go back to your First Visual Studio instance and Open the document that’s failing to render.

  • If there is an exception the second instance of Visual Studio will throw the exact exception and any related information, make sure to read the thrown exception and the InnerException they should guide you to the source of the problem.

That’s it, hope that helps.