In my business layer, i am using WCF service. WCF service instance can be passed in the constructor as well. Here are the constructors of my BL.
private IWCFClient wcfClient;
public MyBL()
:this(new WCFClient())
{
}
public MyBL(IWCFClient wcfClient)
{
serviceClient = wcfClient;
}
because i am declaring my wcfClient as an interface, i dont get .Close() method there. I have to typecast it to close it as ((RealwCFClient)wcfClient).Close();
Is there a way i can close my client without typecasting it? Should i expose a Close method in my interface?
Cast your object to
ICommunicationObjectand then .Close() it.Note that Close() can throw an exception, in this case catch it and do .Abort()