0

(ICommunicationObject)proxy).State gives an error "Cannot obtain fields or call methods on the instance of type 'System.ServiceModel.ICommunicationObject' because it is a proxy to a remote object"

I tried using IClientChannel but still I was getting the same error. This is how I created the factory

IPositionActions positionProxy;

ChannelFactory<IPositionActions> factory = new ChannelFactory<IPositionActions>(Binding, String);

positionProxy = factory.CreateChannel();

I want to access the state to check for the Faulted State of that Channel The state of ChannelFactory is open even if the ClientChannel is not. So, I wanted to check for the state of ClientChannel, positionProxy. But I'm unable to access the state.

When debugging, I'm able to get the state like this. But ServiceChannelProxy and System.Runtime.Remoting.Proxies.__TransparentProxy are not available as they are private.

"((System.ServiceModel.Channels.CommunicationObject)(((System.ServiceModel.Channels.ServiceChannelProxy)((((System.Runtime.Remoting.Proxies.__TransparentProxy)(connectionManager.PositionProxy)))._rp)).serviceChannel)).state"

Please suggest me if there are any ideas to access the state.

Thank you.

Sailoosha
  • 193
  • 1
  • 3
  • 14
  • http://stackoverflow.com/questions/10085779/icommunicationobject-state-do-not-work – Sriram Sakthivel Oct 11 '13 at 14:37
  • Thanks for looking into the question. Yes, I looked into the link you provided. But as I said, I tried using IClientChannel but still I'm getting the same error. I'm using Binding to create by ChannelFactory. I'm not using InstanceContext. Still no clue how to get the state. – Sailoosha Oct 11 '13 at 14:41

0 Answers0