I've got old console app that imports order items to MS-dynamic-nav 2009. It worked before but one day stopped working and I'm not sure why. I've debugged and found that after service.Update all SalesLine become null even if they were initialized before
SalesOrder_PortClient client = new SalesOrder_PortClient(NAVConnect.GetBinding(),NAVConnect.GetEndPointAddress("address")); NAVConnect.NAVWSConnect<SalesOrder_Port>(client); SalesOrder so = new SalesOrder(); client.Create(ref so); so.Sell_to_Customer_No = items.First().CustomerNumber; so.Shipment_Date = items.First().ShipmentDate; so.External_Document_No = items.First().ExternalDocumentNumber; so.Shipping_Agent_Code = items.First().ShippingAgent; client.Update(ref so); so.SalesLines = items.Select(x=>new Sales_Order_Line()).ToArray(); // SalesLines NOT NULL client.Update(ref so); // SalesLines BECOMES NULL for (int i = 0; i < items.Length; i++) { // HERE NullReferenceException so.SalesLines[i].No = items[i].ItemNumber; so.SalesLines[i].Quantity = items[i].Quantity; so.SalesLines[i].Unit_of_Measure_Code = items[i].UOM; so.SalesLines[i].Type = SalesOrderWS.Type.Item; } client.Update(ref so);
Because of that I'm getting NullReferenceException
Anyone can help?
*This post is locked for comments