Problem
If you encounter the below error when in Dynamics CRM while trying to profile a custom workflow plugin using the CRM Plugin Registration utility
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at PluginProfiler.Library.WorkflowXamlUtility.InstrumentStep(XmlNode activityNode, XmlNamespaceManager ns, InstrumentedStepConfiguration step, String workflowAssemblyName)
at PluginProfiler.Library.WorkflowXamlUtility.InstrumentXaml(CrmServiceClient service, String xaml, IList`1 steps)
at PluginProfiler.Library.ProfilerManagementUtility.EnableWorkflow(CrmServiceClient service, String overrideKeyFileName, Guid workflowId, Boolean persistToEntity, String persistenceSessionKey, Boolean includeSecureInformation, Boolean isContextReplay, CustomActivityStep[] workflowSteps)
at Microsoft.Crm.Tools.PluginRegistration.CommonControls.ProfilerSettingsViewModel.btnOk_Click()
Solution
This is a known bug that has existed in the CRM Profiler for quite some time. It assumes that your custom workflow will have an input argument, if it doesn’t then you’ll see that nasty error.
The solution is to add a fake argument to workaround the issue.
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Workflow;
using System;
using System.Activities;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyOrg.CRM.MyPlugin
{
public class DoStuff : CodeActivity
{
// Fake argument to prevent CRM Profiler from crashing
[Input("Fake Argument for Profiler")]
[Default("Fake Argument for Profiler")]
public InArgument MyDummyArgument { get; set; }
//
protected override void Execute(CodeActivityContext activityContext)
{
var serviceFactory = activityContext.GetExtension();
var workflowContext = activityContext.GetExtension();
...
Latest posts by Shane Bartholomeusz (see all)
- Solved: Build Errors Not Showning in VS 2022 - 21st November 2024
- How To: Configure VSCode to Trust Self-Signed Certs - 16th August 2024
- Solved: GitHub Actions – HTTP 403: Resource not accessible by integration - 13th June 2024
Leave a Reply