in my project I need to check if channell is in faulted state before initialize communication on it but I'm getting a cast exception doing it like this:
public class myClass : myInterface
{
private myInterface _service;
public myClass()
{
///service initialization
//.....///
this._service = new ChannelFactory<myInterface>(binding, remoteAddress).CreateChannel();
}
public void login()
{
//This is where i get cast exception
if ((**(ChannelFactory<myInterface>)_service).State** == System.ServiceModel.CommunicationState.Faulted)
{
// re-initialize service
///....
}
}
}