2 small parts to this question which hopefully will clear up some ambiguity for me.
Firstly, which is better for calling a WCF service?
using (var myService = new ServiceClient("httpBinding")){
try{
var customerDetails = GetCustomerDetails();
var results = myService.GetCustomerPurchases(customerDetails);
}catch(Exception e){
......
}
}
or
var myService = new ServiceClient("httpBinding");
try{
var customerDetails = GetCustomerDetails();
var results = myService.GetCustomerPurchases(customerDetails);
}catch(Exception e){
.......
}
What I'm wondering is, should I always be wrapping my service call in a using block? Does IDisposable.Dispose() get called if the service throws an exception?