faulted

ICommunicationObject.State do not work?

假装没事ソ 提交于 2019-12-13 01:28:24
问题 Hi, I create my WCF client with DuplexChannelFactory, the problem is that when I do this : ((ICommunicationObject)this.GetMyServiceInterfaceChannel).State I get the followin exception : Cannot obtain fields or call methods on the instance of type 'System.ServiceModel.ICommunicationObject' because it is a proxy to a remote object. Why? I need to check if the channel is faulted. Edit1: ClientService clientService = new ClientService(); InstanceContext context = new InstanceContext(clientService

How to manage properly an exception in a Task with ContinueWith

非 Y 不嫁゛ 提交于 2019-12-06 22:13:44
问题 After reading information about task and exepcion management, I am using this code to manage an exception thrown in a Task: Task<Object> myTask = Task.Factory.StartNew<Object>(doTask, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); myTask .ContinueWith(task => afterTask(task), TaskScheduler.FromCurrentSynchronizationContext()); Where doTask and AfterTask are: private <Object> doTask() { throw new Exception("BOOM"); } private afterTask(Task<Object> aTask) { if (aTask

How to manage properly an exception in a Task with ContinueWith

廉价感情. 提交于 2019-12-05 03:28:58
After reading information about task and exepcion management, I am using this code to manage an exception thrown in a Task: Task<Object> myTask = Task.Factory.StartNew<Object>(doTask, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); myTask .ContinueWith(task => afterTask(task), TaskScheduler.FromCurrentSynchronizationContext()); Where doTask and AfterTask are: private <Object> doTask() { throw new Exception("BOOM"); } private afterTask(Task<Object> aTask) { if (aTask.IsFaulted) { MessageBox.Show(aTask.Exception.InnerException.Message); } else //whatever } When

What is System.ServiceModel.Diagnostics.CallbackException and why can't I handle it?

自闭症网瘾萝莉.ら 提交于 2019-12-04 23:41:20
问题 In my WCF client class I'm handling the Faulted() event so that if the remote service throws an exception and faults the channel I can still at least shut it down gracefully. Here's my code: protected void RemoteDataRetriever_Faulted(object sender, EventArgs e) { (sender as ICommunicationObject).Abort(); this.Dispose(); throw new ChannelTerminatedException("The remote service threw an unhandled exception and as a result the channel has been closed."); } So what I would expect is that the

WCF Reliable session without transport security will not faulted event on time

佐手、 提交于 2019-12-04 12:01:46
问题 I have encountered a very interesting behavior of reliable session. I am using netTcp binding + duplex channel + reliable session. When I am trying to listen on channel.faulted , if there is security mode is set to transport , faulted event would fire immediately when client disconnects. However when I set binding's security mode to None or Message, faulted event no longer fires in the same situation. They will eventually get faulted half of ReciveTimeout on server side which I understands as

What is System.ServiceModel.Diagnostics.CallbackException and why can't I handle it?

对着背影说爱祢 提交于 2019-12-03 14:41:41
In my WCF client class I'm handling the Faulted() event so that if the remote service throws an exception and faults the channel I can still at least shut it down gracefully. Here's my code: protected void RemoteDataRetriever_Faulted(object sender, EventArgs e) { (sender as ICommunicationObject).Abort(); this.Dispose(); throw new ChannelTerminatedException("The remote service threw an unhandled exception and as a result the channel has been closed."); } So what I would expect is that the client can handle the ChannelTerminatedException that I've thrown manually and send a message to the user,

WCF Reliable session without transport security will not faulted event on time

浪尽此生 提交于 2019-12-03 07:33:15
I have encountered a very interesting behavior of reliable session. I am using netTcp binding + duplex channel + reliable session. When I am trying to listen on channel.faulted , if there is security mode is set to transport , faulted event would fire immediately when client disconnects. However when I set binding's security mode to None or Message, faulted event no longer fires in the same situation. They will eventually get faulted half of ReciveTimeout on server side which I understands as reliable session would send a heart beat message at that time. The question is: Why the wcf binding

How to heal faulted WCF channels?

此生再无相见时 提交于 2019-11-28 09:12:52
When a single ClientBase<T> instance is used for multiple WCF service calls, it can get a channel into a faulted state (ie. when the service is down). I would like to heal the channel automatically when the service comes up again. The only way I found is to call the following code before each method call: if (clientBase.InnerChannel.State == CommunicationState.Faulted) { clientBase.Abort(); ((IDisposable)clientBase).Dispose(); clientBase = new SampleServiceClientBase(); } I got the feeling that this isn't the right way to do it. Anyone got a better idea? Aaronaught You can't. Once a channel is

How to heal faulted WCF channels?

早过忘川 提交于 2019-11-27 02:43:46
问题 When a single ClientBase<T> instance is used for multiple WCF service calls, it can get a channel into a faulted state (ie. when the service is down). I would like to heal the channel automatically when the service comes up again. The only way I found is to call the following code before each method call: if (clientBase.InnerChannel.State == CommunicationState.Faulted) { clientBase.Abort(); ((IDisposable)clientBase).Dispose(); clientBase = new SampleServiceClientBase(); } I got the feeling