We are implementing a webservice (WCF) that uses dotConnect MySQL Entity Framework - LINQ to SQL - to access data.
We have a service method that returns a relational entity object "Company" from the datamodel, but the method throws the following error:
"The underlying connection was closed: A connection that was expected to be kept alive was closed by the server."
It looks like the error occurs because the Company object has a collection of other entity objects "CompanyModules". We tried to set the CompanyModules collection to NULL before returning the entity object and then the error does not occur, but obviously this is not desirable.
Do you have any idea why this is occuring, and if possible how to go about it while maintaining the entity relations?
Error: The underlying connection was closed.
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
We are working with LinqConnect, and here is StackTrace:StanislavK wrote:Could you please specify whether you are working with an Entity Framework or LinqConnect model when this issue occurs? Also, please specify the exception stack trace.
System.Net.WebException.Message: "The underlying connection was closed: A connection that was expected to be kept alive was closed by the server."
System.Net.WebException.StackTrace:
Code: Select all
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at nSales.ServiceClient.Test.WSTest.GetCompany(String accountName) in E:\Mikkel\Dokumenter\Visual Studio 2010\Projects\nSales WebService\nSales.ServiceClient\Web References\Test\Reference.cs:line 114
at nSales.ServiceClient.Form1.button_GetCompany_Click(Object sender, EventArgs e) in E:\Mikkel\Dokumenter\Visual Studio 2010\Projects\nSales WebService\nSales.ServiceClient\Form1.cs:line 141
System.Net.WebException.InnerException.StackTrace:
Code: Select all
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
-
- Devart Team
- Posts: 1710
- Joined: Thu 03 Dec 2009 10:48
I've sent you a test project in a letter, please check that it was not blocked by your mail filter. To run the sample, please perform the following:
- create the tables (please see the letter for the scripts);
- set the proper connection string in the service project;
- publish the service;
- update the service reference in the console application.
Please tell us whether the test project runs properly in your environment. If yes, please specify what should be changed in the sample to reproduce the problem, or send us your test project.
- create the tables (please see the letter for the scripts);
- set the proper connection string in the service project;
- publish the service;
- update the service reference in the console application.
Please tell us whether the test project runs properly in your environment. If yes, please specify what should be changed in the sample to reproduce the problem, or send us your test project.