使用wpf和wcf创建聊天抛出异常 [英] using wpf and wcf creating the chat throw exception

查看:87
本文介绍了使用wpf和wcf创建聊天抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我正在创建聊天,但出现错误,请帮忙该怎么办?


与指定的绑定约束匹配的类型为"WpfApplication6.MainWindow"的构造函数的调用引发了异常.

我在做这样的事
< textbox height ="23" horizo​​ntalalignment ="Left" margin ="162,55,0,0" name ="textBox1" verticalalignment ="Top" width ="120">

解决方案

为了获得更具体的响应,您需要包括内部异常.但是,通常来说,您的绑定之一有问题.在设计时,它不会显示,但在运行时会爆炸. WPF并不总是像C#代码那样为您提供良好的设计时错误消息.


注入到您的项目(解决方案)erorr日志记录系统中. 它可以是任何东西(log4net,NLog等).

Log4net- log4net

订阅Application.DispatcherUnhandledException事件.
当您收到错误消息时,请对DispatcherUnhandledException事件进行一些事件登录.
另外,如果您捕获了窗口异常并且不将其推到捕获边界之外,请执行以下操作:

 ....
....
捕获(例外)
{
....一些工作流程
投掷; -将其推送到DispatcherUnhandledException 事件处理程序.
} 


hi I am creating chat and i am getting the error please help what to do?


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

I a m doing like this
<textbox height="23" horizontalalignment="Left" margin="162,55,0,0" name="textBox1" verticalalignment="Top" width="120">

解决方案

In order for a more specific response, you would need to include the inner exception. However, in general, one of your bindings has a problem. At design time it won''t show up, but it will blow up at runtime. WPF does not always give you good design-time error messages like the C# code does.


Inject to your projects(solution) erorr logging system.
It coud be anything (log4net,NLog, etc.).

Log4net - log4net

Subscribe to Application.DispatcherUnhandledException event.
and when you get an error , do some log in event hadler method on DispatcherUnhandledException event.
Also, if you catch in your window exceptions and do not push them outside catch boundaries , do somethink like that:

....
....
catch(Exception ex)
{
.... some workflow here
throw; - that will push it to DispatcherUnhandledException event handler.
}


这篇关于使用wpf和wcf创建聊天抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆