0

我在 VS 2017 中为自定义 wf 程序集进行了构建。

以下是我的代码。没有红色波浪线并且注册没有错误:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using Microsoft.Xrm.Sdk.Query;

namespace CustomerAsset
{
    public partial class CustomerAsset : CodeActivity
    {

        //public InArgument<EntityReference> CustomerAsset { get; set; }
        protected override void Execute(CodeActivityContext executionContext)
        {

            //Create the tracing service
            ITracingService tracer= executionContext.GetExtension<ITracingService>();
            tracer.Trace("Begin Plugin Execution");
            //Create the context
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

            try
            {
                //DO WORK HERE
                Entity entity = (Entity)context.InputParameters["Target"];

                var targetCustAssOpHrsId = entity.Id;
                tracer.Trace(entity.LogicalName);
                tracer.Trace(targetCustAssOpHrsId.ToString());

                QueryExpression qe = new QueryExpression();
            }
            catch(Exception ex)
            {
                throw new InvalidPluginExecutionException("error in CustomerAsset custom workflow assembly");
                //throw new InvalidPluginExecutionException(ex);
            }
        }
    }
}

以下是我已经尝试过的:

  • 重新编译为 .NET 4.5.2
  • 确保将核心程序集定位为正确的 d365 v9 在线版本

还有其他陷阱吗?我使用的是开发指南而不是以前的 SDK,所以这对我来说有点新。

从代码中可以看出。我只是在追踪。我在实例化跟踪器后抛出了一个跟踪写入,甚至没有做到这一点。

另请注意,我按需运行此命令以测试执行。

4

1 回答 1

1

您可能需要检查插件跟踪设置是否设置为“全部”。

(设置 > 管理 > 系统设置 > 自定义)

截屏

您还可以尝试在代码中抛出异常以查看该异常是否已注册。

在 D365 中更新 Plugin Assembly 后,检查解决方案以确保 ModifiedOn 已更改。

于 2018-12-10T20:30:02.340 回答