I did a build for a custom wf assembly in VS 2017.
The following is my code. There is no red squigglies and registered without error:
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);
}
}
}
}
The following is what I already attempted:
Is there any other gotchas? Im using dev guide rather than previous SDK so this is a bit new to me.
As you can see from code. I am just tracing. I threw a trace write after instanciating tracer and doesn't even get to that.
Also note, Im running this on-demand to test execution.
You might want to check if the Plugin Tracing setting is set to "All".
(Settings > Administration > System Settings > Customization)
You could also try throwing an exception in the code to see if that registers.
After updating the Plugin Assembly in D365, check the solution to ensure that the ModifiedOn has changed.