Click here to Skip to main content
15,891,745 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
(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

C#
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.

C#
((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.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900