Skip to content

Null reference exception when performing INSTRUMENT operation #484

@arp-mbender

Description

@arp-mbender

After some debugging I found the problem:

                        attribute = new CrmPluginRegistrationAttribute(
                            step.sdkmessageid_sdkmessageprocessingstep.Name,
                            filter == null ? "none" : filter.PrimaryObjectTypeCode,
                            (StageEnum)Enum.ToObject(typeof(StageEnum), step.Stage.Value),
                            step.Mode.Value == 0 ? ExecutionModeEnum.Synchronous : ExecutionModeEnum.Asynchronous,
                            step.FilteringAttributes,
                            step.Name,
                            step.Rank.HasValue ? step.Rank.Value : 1,
                            step.plugintypeid_sdkmessageprocessingstep.pluginassembly_plugintype.IsolationMode == pluginassembly_isolationmode.Sandbox
                                ? IsolationModeEnum.Sandbox : IsolationModeEnum.None
                            )
                        {
                            Id = step.Id.ToString(),
                            DeleteAsyncOperation = step.Mode.Value != 0 && step.AsyncAutoDelete.Value, // <- in this line step.AsyncAutoDelete is NULL; this needs a null check
                        };

An example fix would be to replace the latter part of the logic operator with step.AsyncAutoDelete == true.

However, on top of that, it seems the query used to populate the step lacks the AsyncAutoDelete completely, meaning this is always null.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions