WCF "DataContext accessed after Dispose"
- by David Ward
I have an application with numerous WCF services that make use of LINQ-To-SQL as the data access model. I am having lots of problems with the "DataContext accessed after Dispose" exception. I understand what this exception is and that it is occurring because I have not "initialised" the data that is trying to be accessed. I've read many articles that suggest that I called ToList() on any arrays before the parent object is returned by the service.
My issue is that I am getting this exception and I don't know where it is originating from and therefore I don't know what hasn't been initialised.
Can anyone advise how best to identify the root cause?
(I have used the MS Service Trace Viewer and this doesn't seem to give me any further information)