How do I correctly manage the disposing of a DataContext?
问题 I have a web service that is quite heavy on database access. It works fine in test, but as soon as I put it in production and ramp up the load it starts churning out errors that are raised when something calls a method in the DataContext. The error is normally one of these: Object reference not set to an instance of an object Cannot access a disposed object. Object name: 'DataContext accessed after Dispose.'. but not always. Any single web service requests can result as many as 10 or 15