I have a WPF Desktop Bridge app in the store. In the App Center I can see that some installations throw a XamlParseException in Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri) during the call to MainWindow.InitializeComponent() . On my developer PC everything works fine. However, the Xaml designer underlines CommandBindings in the MainWindow.xaml file as warnings.

namespace CompactStore  
	public static partial class CustomCommands  
		public static RoutedCommand	NewFolder = new RoutedCommand();  
		public static RoutedCommand	Delete = new RoutedCommand();  
		public static RoutedCommand	NewCompactStore = new RoutedCommand();  
		public static RoutedCommand	OpenCompactStore = new RoutedCommand();  
		public static RoutedCommand	OpenHistorie = new RoutedCommand();  
		public static RoutedCommand	Extract = new RoutedCommand();  
		public static RoutedCommand	Insert = new RoutedCommand();  
		public static RoutedCommand	InsertFromClipboard = new RoutedCommand();  
		public static RoutedCommand	CopyToClipboard = new RoutedCommand();  
		public static RoutedCommand	Move = new RoutedCommand();  
		public static RoutedCommand	OpenSettings = new RoutedCommand();  
		public static RoutedCommand	Enter = new RoutedCommand();  
		public static RoutedCommand	OpenWith = new RoutedCommand();  
		public static RoutedCommand	GotoPrevious = new RoutedCommand();  
		public static RoutedCommand	GotoNext = new RoutedCommand();  
		public static RoutedCommand	GoUp = new RoutedCommand();  
		public static RoutedCommand	Find = new RoutedCommand();  
		public static RoutedCommand	Search = new RoutedCommand();  
		public static RoutedCommand	Rename = new RoutedCommand();  
		public static RoutedCommand	MoveDividerLeft = new RoutedCommand();  
		public static RoutedCommand	MoveDividerRight = new RoutedCommand();  
		public static RoutedCommand	ShowDoublets = new RoutedCommand();  
		public static RoutedCommand	DeepList = new RoutedCommand();  
		public static RoutedCommand	Help = new RoutedCommand();  
		public static RoutedCommand	ShowAppInfo = new RoutedCommand();  
		public static RoutedCommand	Play = new RoutedCommand();  
		public static RoutedCommand	Space = new RoutedCommand();  
		public static RoutedCommand	Mute = new RoutedCommand();  

How can I determine what problem the installations have with the xaml file (line, offset)?

This is the first app where I use custom commands. Is there another way to implement custom commands, so that the xaml designer does not give warnings?

Hi HuiLiu,

The warning I get from the Xaml designer, is visible in the screenshot above. Intellisense shows wrong errors (see image below). Whether the definition of the CommandBindings has anything to do with the XamlParseException is only a guess.

The CommandBindings are defined in the namespace CompactStore (see image in my first post).

In the app I catch an unhandled exception and send the stack trace along with some other information to the App Center. The original error message is in Polish, as the exception currently occurs in Polish installations. I'll show you the English translation. Here is the info I see in AppCenter:

XamlParseException
"Calling the constructor for the type "CompactStore.MainWindow" that conforms to the specified constraints of the binding caused an exception."

at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReaderxamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
at System.Windows.Application.DoStartup()
at System.Windows.Application.<.ctor>b__1_0(Object unused)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Exception.HResult: 0x80131501; X64, Windows.Desktop, WINDOWS 10.0.19042.1237

The exception also occurs under WINDOWS 10.0.19043.1237.

I use VS 2017 Community Edition.

Hi,@ Heiko-6891.
It is a common error with multiple causes and solutions, you could try the following methods to see if it works for you.
Method one:

  • Close Visual Studio
  • Delete the hidden .vs folder
  • Open Visual Studio and rebuild your project
  • It may be a compiler problem, and xaml designer may not be able to recognize it in Debug mode.
    Method two:

  • Right click on your solution (Solution) -> Properties -> Configuration Properties -> go from Debug mode to Release mode
  • Re-Build your solution.
  • After the problem is solved, you can change back to Debug mode.
    You could also try to refer here.
  • Thank you, unfortunately Intellisense continues to give me the same errors after deleting ".vs" and build the release mode.

    My main problem is still the XamlParseException that occurs with some users. On my system this exception does not occur. How can I still check what is causing this exception for users?

    I created a test project. In it is the same xaml file that is in the real project and causes a XamlParseException in some installations. All handlers specified in the file have no function in the code-behind.

    Test project

    On some installations (different devices, different Windows 10 versions) I get the following message in the App Center:

    XamlParseException

    The invocation of the constructor on type 'CompactStore.MainWindow' that matches the specified binding constraints threw an exception.

    at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
    at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
    at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
    at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
    at System.Windows.Application.LoadBamlStreamWithSyncInfo(Stream stream, ParserContext pc)
    at System.Windows.Application.DoStartup()
    at System.Windows.Application.<.ctor>b__1_0(Object unused)
    at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
    at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

    0x80131501

    After the patch update December 13, 2022-KB5021085 Cumulative Update for .NET Framework 3.5, 4.7.2 and 4.8 for Windows 10, version 1809 and Windows Server 2019 , while installation our window based application we are getting error.

    error

    An exception of type 'System.Windows.Markup.XamlParseException' occurred and was caught.
    ----------------------------------------------------------------------------------------
    12/27/2022 08:51:37
    Type : System.Windows.Markup.XamlParseException, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    Message : 'Initialization of 'Xceed.Wpf.Toolkit.Wizard' threw an exception.' Line number '617' and line position '19'.
    Source : PresentationFramework - AliOffice AssemblyVersion: 5.3.1.0
    Help link : 
    LineNumber : 617
    LinePosition : 19
    KeyContext : 
    UidContext : 
    NameContext : 
    BaseUri : pack://application:,,,/DAIOffice;component/deployment/ui/setup.xaml
    Data : System.Collections.ListDictionaryInternal
    TargetSite : Void RewrapException(System.Exception, System.Xaml.IXamlLineInfo, System.Uri)
    HResult : -2146233087
    Stack Trace :    at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
       at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
       at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
    

    can same guide how to fix this issue

    It may help to enclose the code in the constructor with a try-catch block and log the exception. In my case an exception occurred in the constructor of MainWindow (and it wasn't a XamlParseException, but led to one).

    public MainWindow()
    		// To do...
    	catch (Exception ex)
    		// Report the exception here.
    		throw;