0
  public List<dynamic> GetDynamicResult()
        {
            List<dynamic> lstDynamic = new List<dynamic>();
            lstDynamic.Add(new { ID = "1", Name = "ABC" });
            lstDynamic.Add(new { ID = "1", Name = "XYZ" });
            return lstDynamic;
        }

When i return List from WCF to ASP.NET web App using List<dynamic> lstDynamic = objClient.GetDynamicResult(); I get this error: The underlying connection was closed: The connection was closed unexpectedly

1 Answer 1

2

WCF needs to define a DataContract (serialization is used) which is sent by wire. Using dynamic types conflict with this. You can use string combine with (de)serialization instead.

Sign up to request clarification or add additional context in comments.

2 Comments

thank for ur reply it would be nice if u can gimme a simple example
For start change function to public string GetDynamicResult() { etc }. After that you can pack everything to XML and than to string. At client side you can unpack from string to XML and than to .NET object. Very good link related for this topic

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.