Click here to Skip to main content
15,921,276 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there. I faced the problem debugging my WPF-WCF simple chat application. There's an exception like:
XamlParseException was unhandled. 'The invocation of the constructor on type 'ChatGUI.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'.

I see that's a XAML exception, so here's the XAML code listing:
<Window x:Class="ChatGUI.MainWindow"
        Title="MainWindow" Height="350" Width="525">
            <RowDefinition Height="35*" />
            <RowDefinition Height="35" />
        <TextBox Height="Auto" HorizontalAlignment="Stretch" Margin="6,6,6,6" Name="textBoxChatPane" VerticalAlignment="Stretch" Width="Auto" Grid.Row="0" />
        <TextBox Height="23" HorizontalAlignment="Stretch" Margin="6,6,6,6" Name="textBoxEntryField" VerticalAlignment="Stretch" Width="Auto" Grid.Row="1" KeyDown="textBoxEntryField_KeyDown" />

Have you ever seen the same problem? I would be glad to see every useful advice.
Thanks in advance.
Updated 5-Jan-12 17:12pm
valecoder 5-Jan-12 17:50pm    
The same cs class:

namespace ChatGUI
/// Interaction logic for MainWindow.xaml

public partial class MainWindow : Window
private ChatBackend.ChatBackend _backend;

public MainWindow()
_backend = new ChatBackend.ChatBackend(this.DisplayMessage);

public void DisplayMessage(ChatBackend.CompositeType composite)
string username = composite.Username == null ? "" : composite.Username;
string message = composite.Message == null ? "" : composite.Message;
textBoxChatPane.Text += (username + ": " + message + Environment.NewLine);

private void textBoxEntryField_KeyDown(object sender, KeyEventArgs e)
if (e.Key == Key.Return || e.Key == Key.Enter)

1 solution

My guess is that this line:
_backend = new ChatBackend.ChatBackend(this.DisplayMessage);
throws an exception.

Try setting a breakpoint on the line and debug your application.

If you open the App.xaml, you'll see that the ChatGUI.MainWindow is referenced there.

Best regards
Espen Harlinn
Share this answer
valecoder 5-Jan-12 18:09pm    
Yep. I've just done that. And the point is in this line.
Wendelius 5-Jan-12 18:11pm    
Spot on, +5.

Perhaps it's a personal problem but I find the error handling in XAML window constructors a bit annoying. It would be nice if the debugger would actually stop on the problem statement when an unhandled exception is raised regardless of the compile settings but...
Espen Harlinn 5-Jan-12 18:16pm    
Thanks Mika!
You can change the behaviour using Mainmenu->Debug->Exceptions
Wendelius 5-Jan-12 18:22pm    
Yes, but id I remember correctly, this doesn't apply for release builds, even if run from Visual Studio :)
Espen Harlinn 5-Jan-12 18:24pm    
So that's what you meant by "regardless of the compile settings" :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900