当前位置:编程学习 > wap >>

WP7中EndpointNotFoundException的异常捕获

WP7调用webservice时服务端未启动会报错。
“System.ServiceModel.EndpointNotFoundException”类型的未经处理的异常在 System.ServiceModel.dll 中发生 。
因此想添加EndpointNotFoundException的异常捕获,但是不知道怎么捕获这里的异常求指点。


servicePortTypeClient client=new servicePortTypeClient();
client.initAsync();
client.initcomleted+=(s,e)=>
{
MessageBox.Show(e.Result.Message.ToString());
}
异常 webservice --------------------编程问答-------------------- EndpointNotFoundException

意思是找不到服务器... --------------------编程问答-------------------- 对啊 服务器端我没开啊

由于远程终结点关闭、远程终结点无法访问,或者由于远程网络无法访问,因此可能找不到或无法访问终结点。

实际运行中也会有服务器端关闭的情况吧。我肯定不能让程序莫名其妙的退出啊。。

求助怎么try catch一下。。 --------------------编程问答--------------------
引用 1 楼 cuit 的回复:
EndpointNotFoundException

意思是找不到服务器...

求助 --------------------编程问答-------------------- 你把这些都try catch住试试

client.initAsync();
client.initcomleted+=(s,e)=>
{
MessageBox.Show(e.Result.Message.ToString());
} --------------------编程问答--------------------
引用 4 楼 cuit 的回复:
你把这些都try catch住试试

client.initAsync();
client.initcomleted+=(s,e)=>
{
MessageBox.Show(e.Result.Message.ToString());
}

试过了···没用。。。依然报错 --------------------编程问答--------------------
引用 5 楼 oubenruing 的回复:
Quote: 引用 4 楼 cuit 的回复:

你把这些都try catch住试试

client.initAsync();
client.initcomleted+=(s,e)=>
{
MessageBox.Show(e.Result.Message.ToString());
}

试过了···没用。。。依然报错


你服务器开了的时候是什么情况? --------------------编程问答--------------------
引用 6 楼 cuit 的回复:
Quote: 引用 5 楼 oubenruing 的回复:

Quote: 引用 4 楼 cuit 的回复:

你把这些都try catch住试试

client.initAsync();
client.initcomleted+=(s,e)=>
{
MessageBox.Show(e.Result.Message.ToString());
}

试过了···没用。。。依然报错


你服务器开了的时候是什么情况?

开了就正常运行了= =
弹出messagebox 显示消息··· --------------------编程问答-------------------- 你这是为了测试异常case? --------------------编程问答--------------------
引用 8 楼 cuit 的回复:
你这是为了测试异常case?

也不是 

因为我初始化程序的时候需要连接webservice获取数据 

如果连接失败我想要得到连接失败的消息

目前就想到捕获异常来得到连接失败的消息

结果这个还捕获不了异常。。纠结呀
补充:移动开发 ,  Windows Phone
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,