tags:

views:

329

answers:

0

Hi,

  • .net service to .net client with shared POCO (data objects) library at both ends.
  • Object OrderInfo contains a List. If the list contains any Module objects I get the dreaded "The underlying connection was closed: The connection was closed unexpectedly."
  • I can send a "standalone" List from another service method and it works fine so Module object by themselves serialize/deserialize fine.
  • I don't use datacontract in the POCO classes, WCF handles this automatically (which might also be the problem. I've tried adding:

    [Serializable]
    [XmlInclude(typeof(List<Module>))]
    

but that didn't help. I can't see what the problem is since I do THE EXACT SAME thing in the Module object returning a collection of Pricemodel objects.

    public class OrderInfo
    {
    int _ProductID;
    IList<Module> _Modules = new List<Module>();
    //IList<MiscProduct> _MiscProduct = new List<MiscProduct>();

    public IList<Module> Modules
    {
        get
        {
            return new List<Module>(_Modules).AsReadOnly();
        }
        set
        {
            _Modules = value;
        }
    }
    }

    public class Module
    {
    string _Name;
    int _Sort_Number;
    string _Description;
    OrderInfo _OrderInfoMaster;
    IList<Pricemodel> _Pricemodels = new List<Pricemodel>();

    public IList<Pricemodel> Pricemodels
    {
        get
        {
            return new List<Pricemodel>(_Pricemodels).AsReadOnly();
        }
        set
        {
            _Pricemodels = value;
        }
    }
    }

Calling client code is:

    using (ProductOrderItems_WCFService.ProductOrderServiceClient client = new ProductOrderItems_WCFService.ProductOrderServiceClient())
    {
        string s = client.HelloWorld();
        Module m = client.GetModule();
        List<Module> mods = client.GetModuleList(7);
        grdModules.DataSource = mods;
        grdModules.DataBind();

        OrderInfo oi = client.GetOrderInfo(7);
    }

It fails on the last line when I request OrderInfo object from service. All the above calls work great.