Losing control of execution trace upon method return

45 views Asked by At

I am keeping track of the execution through a trace. In my current method I can see the execution log and interrupt the execution with an exception to verify that everything is in order:

tracingService.Trace("Create History for new Active Saleslist");
Entity salesList = service.Retrieve(postList.LogicalName, postList.Id, new ColumnSet(new String[] { "custom_saleslistid" }));
tracingService.Trace("sales list id : " + salesList.Id);
SalesListLogic salesListLogic = new SalesListLogic(context, service, tracingService, salesList);
salesListLogic.CreateSalesHistoryRecord(new EntityReference(entity.LogicalName, entity.Id));
tracingService.Trace("Remove History for old Active Saleslist");
Entity preSalesList = service.Retrieve(preList.LogicalName, preList.Id, new ColumnSet(new String[] { "custom_saleslistid" }));
SalesListLogic preSalesListLogic = new SalesListLogic(context, service, tracingService, preSalesList);
preSalesListLogic.DeleteSalesHistoryRecord(new EntityReference(entity.LogicalName, entity.Id));

I can also do it in the DeleteSalesHistoryRecord method.

public void DeleteSalesHistoryRecord(EntityReference slotRef)
{

    tracingService.Trace("retrieving saleshistory");
    QueryExpression historyQuery = new QueryExpression("custom_saleshistory");
    historyQuery.ColumnSet = new ColumnSet(true);
    historyQuery.Criteria.AddCondition("custom_slot", ConditionOperator.Equal, slotRef.Id);
    historyQuery.Criteria.AddCondition("custom_saleslist", ConditionOperator.Equal, record.Id);

    var historyRecords = service.RetrieveMultiple(historyQuery);


    if (historyRecords.Entities.Count == 1)
    {
        tracingService.Trace("deleting saleshistory");
        Entity historyRecord = historyRecords.Entities[0];
        service.Delete(historyRecord.LogicalName, historyRecord.Id);
    }
    tracingService.Trace("Done deleting the record");
}

The problem is that if I put a statement to throw an Exception after the method call, no exception is raised. If I put an exception before quitting than the trace is empty.

I cannot debug the code, since the code is published in an on cloud deployment without server access. What's going on?

0

There are 0 answers