0

I'm getting a System.ObjectDisposedException with the following code:

using (AdminServiceClient web Service = new AdminServiceClient)
{
    webService.Open();
    ...
    var jsonToReturn = new { 
        ...
        data = addresses.Select(address => new string [] {
            ...
            webService.GetAddressName(address.id)
            ...
        }) // running the code results in the exception here
    }; 
    return Json(jsonToReturn, JsonRequestBehavior.AllowGet);
}

I'm assuming the exception comes from that one method call to GetAddressName(). Is there any way to force the execution of that method before exiting the using block?

LOL. NO.
  • 577
  • 1
  • 6
  • 33
  • Is that an async method you're calling? If so, you should have to instruct your code to wait. – jleach Jun 13 '16 at 17:12
  • @jdl134679 GetAddressName isn't an Async method. Neither is the method that's using the using block. – LOL. NO. Jun 13 '16 at 17:16
  • [Do not use `using` with WCF clients](https://msdn.microsoft.com/en-us/library/aa355056(v=vs.110).aspx) – Tim Jun 13 '16 at 17:21

0 Answers0