方法返回时失去对执行跟踪的控制

时间:2015-06-24 12:20:12

标签: c# debugging dynamics-crm trace

我通过跟踪跟踪执行情况。 在我当前的方法中,我可以看到执行日志并中断执行,但有一个例外,即验证一切是否正常:

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));

我也可以在 DeleteSalesHistoryRecord 方法中执行此操作。

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");
}

问题是如果我在方法调用之后放置一个语句来抛出异常,则不会引发异常。 如果我在退出前放置一个异常,那么跟踪是空的。

我无法调试代码,因为代码是在没有服务器访问权限的云部署中发布的。 发生了什么事?

0 个答案:

没有答案