chao's profile清凉水都PhotosBlogListsMore ![]() | Help |
|
July 16 WCF服务端发送自定错误[ServiceContract] [FaltException(typeof(CustomException))] CustomException是序列化数据 ServiceDebugBehavior debug = new ServiceDebugBehavior(); debug.IncludeExceptionDetailInFaults = fales; ServiceHost.Description.Behaviors.Add(debug)前要先清除自动生成Debug行为 ServiceHost.Description.Behaviors.Remove<ServiceDebugBehavior>();因为会自动生成而Behaviors是一个KeyTypeOfCollection,因此无法容下两个同类型的对象。
客户端截获用Cath(FaultException<CustomException> ex),注意这个ex的类型是FaultException,如果想要用自己的错误类型,需要这样:ex.Details,这样返回的就是CustomException了,之后就可以获取自定的信息和操作了。 TrackbacksThe trackback URL for this entry is: http://ebakeshop.spaces.live.com/blog/cns!1A66D6C80502E805!362.trak Weblogs that reference this entry
|
|
|