WCF- "Connected connection was closed: connection was unexpectedly closed"

I get an amazing ambiguous error message when using one of my web methods in my WCF web service. Since this error message provides no explanation, let me post my theory.

I suppose this may have something to do with the type of return I'm using

I have a type DLL that is redefined in both the webservice and the client. This DLL uses the base class ExceptionMessages. There is a child of this DrawingExcepions class.

Here is the code:

public class ExceptionMessages
{
    public object[] ReturnValue { get; set; }
}

public class DrawingExceptions : ExceptionMessages
{
    private List<DrawingException> des = new List<DrawingException>();
}

public class DrawingException
{
    public Exception ExceptionMsg { get; set; }
    public List<object> Errors { get; set; }
}

Code Usage:

    [OperationContract]
    ExceptionMessages createNewBom(Bom bom, DrawingFiles dfs);

    public ExceptionMessages createNewBOM(Bom bom, DrawingFiles dfs)
    {
            return insertAssembly(bom, dfs);
    }

    public DrawingExceptions insertAssembly(Bom bom, DrawingFiles dfs)
    {
        DrawingExceptions des = new DrawingExceptions();

        foreach (DrawingFile d in dfs.drawingFiles)
        {
            DrawingException temp = insertNewDrawing(bom, d);
            if (temp != null)
                des.addDrawingException(temp);

            if (d.Child != null)
                des.addDrawingException(insertAssembly(bom, d.Child));
        }

        return des;
    }

Return to:

    ExceptionMessages ems = client.createNewBom(bom, currentDFS);

    if (ems is DrawingExceptions) { }

Basically, the return type from the web method is ExceptionMessages, but usually I send a child class.

, , , , , . - - , ?

, :)

.

+5
4

, :)

, . " ".

+4

, , DataContractSerialiser , maxItemsInObjectGraph , , .

<dataContractSerializer maxItemsInObjectGraph="2147483647" />
+2

, , WCF. squig . , , , .

, , , .. , . , , , , , , ..

edmx, , .

, - !

+2

I had the same problem, however, none of the answers above solved the problem.

I returned a list of LINQ objects, the database has all relations set correctly, which causes the objects to communicate automatically with LINQ ... This stopped the request from working.

I solved this by deleting the relationship from LINQ DBML

0
source

All Articles