我使用以下代码获取System.ObjectDisposedException:
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);
}
我假设异常来自对GetAddressName()的一个方法调用。有没有办法在退出using块之前强制执行该方法?