Custom NodeModel Error: Dereferencing a non-pointer

I’m attempting to create a very simple custom NodelModel, but with no success, an Error: Dereferencing a non-pointer keeps apperaing. Dynamo version:

If no input is connected, the node shows gray as normal, but if two numbers are connected as input I get:

I’ve been following the same structure of other Dynamo nodes, so I cannot explain myself what’s wrong or missing. The node simply multiplies two numbers, below the full code:

using System;
using System.Collections.Generic;
using Dynamo.Graph.Nodes;
using ProtoCore.AST.AssociativeAST;

namespace TestNodeModel
  [NodeDescription("Test Node")]
  [InPortNames("A", "B")]
  [InPortTypes("double", "double")]
  [InPortDescriptions("Number A", "Numnber B")]
  public class TestNodeModel : NodeModel
    public TestNodeModel()

    public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
      if (!HasConnectedInput(0) || !HasConnectedInput(1))
        return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), AstFactory.BuildNullNode()) };

      var functionCall =
          new Func<double, double, double>(DoCalc),
          new List<AssociativeNode> { inputAstNodes[0], inputAstNodes[1] });

      return new[] { AstFactory.BuildAssignment(GetAstIdentifierForOutputIndex(0), functionCall) };

    public static double DoCalc(double a, double b)
      return a * b;

Disclaimer: I know practically no C#

However, built a dll using the exact same code posted above and imported it in the latest daily build (1.1)
Worked for me.

Vikram, thanks for your help.
It looks like you have loaded the dll as a ZeroTouch node and accessed the DoCalc method diretly, while I’m testing it as a NodeModel for which you need the whole package.

I’ve attached a copy of it if you want to test:

SOLUTION from Ian: the DoCalc method has to be in a separate assembly.


Sharing a repo containing the source code fore those interested:
The separate assembly has to be loaded into dynamo directly, so it has to be declared the pkg.json file as well.

1 Like