Как я могу найти источник ошибки объекта связи, когда моя трассировка стека пуста? - PullRequest
0 голосов
/ 26 апреля 2019

У меня есть программа на C # .net. Я добавил try / catch в сегмент кода и теперь получаю ошибку связи. Трассировка стека пуста, трассировка стека сервера не показывает никаких строк в моем коде, а внутреннее исключение пусто. Код внутри try / catch составляет около 100 строк. Как точно определить источник ошибки?

Я не заметил этой ошибки, пока не добавил try / catch внутри метода handleShipmentBusinessRules.

Вот сообщение об ошибке:

Сообщение об ошибке: объект связи, System.ServiceModel.Channels.ClientFramingDuplexSessionChannel, не может быть использованы для связи, потому что он находится в состоянии неисправности. стек трассировка: трассировка стека сервера: в System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen () в System.ServiceModel.Channels.OutputChannel.BeginSend (Сообщение сообщение, время ожидания TimeSpan, обратный вызов AsyncCallback, состояние объекта) в System.ServiceModel.Dispatcher.DuplexChannelBinder.BeginRequest (Message сообщение, время ожидания TimeSpan, обратный вызов AsyncCallback, состояние объекта) в System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartSend (Boolean завершено синхронно) в System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.FinishEnsureOpen (IAsyncResult результат, логическое завершение синхронно) в System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartEnsureOpen (Boolean завершено синхронно) в System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.FinishEnsureInteractiveInit (IAsyncResult результат, логическое завершение синхронно) в System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.StartEnsureInteractiveInit () в System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.Begin () в System.ServiceModel.Channels.ServiceChannel.BeginCall (String действие, логическая односторонняя операция, операция ProxyOperationRuntime, Object [] ins, TimeSpan timeout, обратный вызов AsyncCallback, объект asyncState) в System.ServiceModel.Channels.ServiceChannel.BeginCall (ServiceChannel канал, операция ProxyOperationRuntime, Object [] ins, AsyncCallback обратный вызов, объект asyncState) в System.Threading.Tasks.TaskFactory 1.FromAsyncImpl[TArg1,TArg2,TArg3](Func 6 beginMethod, Func 2 endFunction, Action 1 endAction, TArg1 arg1, TArg2 arg2, TArg3 arg3, Состояние объекта, TaskCreationOptions creationOptions)
в System.Threading.Tasks.TaskFactory 1.FromAsync[TArg1,TArg2,TArg3](Func 6 beginMethod, Func`2 endMethod, TArg1 arg1, TArg2 arg2, TArg3 arg3, Состояние объекта) в System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.CreateGenericTask [Т] (ServiceChannel канал, операция ProxyOperationRuntime, Object [] inputParameters)
в System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.CreateGenericTask (ServiceChannel канал, операция ProxyOperationRuntime, Object [] inputParameters)
в System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.CreateTask (ServiceChannel канал, IMethodCallMessage methodCall, ProxyOperationRuntime операция) в System.ServiceModel.Channels.ServiceChannelProxy.InvokeTaskService (IMethodCallMessage methodCall, операция ProxyOperationRuntime) в System.ServiceModel.Channels.ServiceChannelProxy.Invoke (Шеззаде сообщение)

Исключение переброшено в [0]: в System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage (Шеззаде reqMsg, IMessage retMsg) в System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (MessageData & msgData, тип Int32) в BusinessLogicLayer.ShipService.IShipService.ShippingMethods_GetByDishbooksCodeAsync (String DishbooksCode) в BusinessLogicLayer.ShipmentsBLL.handleShipmentBusinessRules (Корабль, DishbooksOrder dbOrder) Внутреннее исключение:

Вот часть кода:

public ShipmentDTO ProcessShipment(ShipAFilterDTO ShipAFilterDTO, bool TestShipment = false, bool RelieveInventory = true, bool AdjustGP = true, bool DeveloperMode = true)
{
        try
        {
            Ship ship = new Ship();
            ship = retrieveOrderDataIntoShipObject(ShipAFilterDTO);
            ship = shipClient.ProcessShipmentAsync(ship, TestShipment).Result;
        }
        catch (Exception ex)
        {
            //Voids the Shipment / Tracking Number, since something went wrong


shipClient.Shipment_VoidByTrackingNumberAsync(ship.TrackingNumber).Wait();
                       throw;
            }
        }

private Ship retrieveOrderDataIntoShipObject(ShipAFilterDTO ShipAFilterDTO)
{
    using (DishbooksUnitOfWork dbUnitOfWork = new DishbooksUnitOfWork(bllSettings.DishbooksConnectionString))
    {
        Ship ship = new Ship();

        ... Get some data here ...

        // Populate Ship
        ship.Notes = dbOrder.SpecialHandlingNotes + " ";
        ship.PackageNumber = 1;

        handleShipmentBusinessRules(ship, dbOrder);

            return ship;
    }
}


private void handleShipmentBusinessRules (Ship ship, DishbooksOrder dbOrder)
{
    try
    {
            if (dbOrder.IsWillCallOrder == true)
            {
                ship.ShippingCarrier = ShippingCarriers.Manual;
                ship.ShippingMethodCode = ShippingMethods.ManualShip;
                ship.Notes += "Will-Call - Please Take to NT Front-Desk ";
            }
            else if (dbOrder.IsFreight == true || (!string.IsNullOrEmpty(dbOrder.RequestedShipper) && dbOrder.RequestedShipper.ToUpper() == "FREIGHT"))
            {
                ship.ShippingCarrier = ShippingCarriers.Manual;
                ship.ShippingMethodCode = ShippingMethods.ManualShip;
                ship.Notes += "Freight Order - Please Take to Freight Shipping Area ";
            }

        ... Additional populating of ship object

    }
    catch (Exception ex)
    {
        logger.Error(@"Error in ShipmentsBLL.cs/handleShipmentBusinessRules." +
                         Environment.NewLine + "Error Message: " + ex.Message +
                         Environment.NewLine + "Stack trace: " + ex.StackTrace +
                         Environment.NewLine + "Inner exception: " + ex.InnerException);
                throw;
    }
}

Класс Ship принадлежит стороннему инструменту, который берет переданную информацию и печатает этикетку доставки.

...