Sanity Check : Anyone doing Linq to SQL under 4.0 framework and WCF?
-
I converted my 2008 / .NET 2.0 data service to VS2010 with the 4.0 framework. I can do my normal test: http://localhost:4440/datareflector.svc and I get my wsdl screen. If I click the link I get all of my WSDL as expected. So nothing is wrong there. My data structure uses Linq to Sql to connect to he database and extract information. The applications' service reference has all of the data in it correctly. When I call the service I get a report that the service terminated. When I attach my code to the service and enter debug the results totally floor me: my code pattern is simple:
public things\[\] GetMyThings( Guid myIdentity ) { using ( MyContext context = new MyContext( connectionString ) ) { var mt = from t in context.ThingTable where t.Identity == myIdentity select t; return mt.ToArray(); } }\*
When I walk through this simplistic code, I can confirm that mt ends up populated with the rows and values expected and goes through the return code just fine. At the end of the walk (the bracket marked with the *) when I hit F11 I get the exception InvalidOperationException ' Attempting to access an object (context) that has been disposed. ' I cannot, for the life of me, figure this one out. About to wipe my machine and do a full reinstall just to see if that cleans up everything. This is an issue no one seems to have an answer for. Has ANYONE experienced this kind of issue?