# Dynamo 2.0 duplicates ports of custom node when file is saved and reopened?

**URL:** <https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867>\
**Category:** Developers\
**Created:** [April 9, 2018, 4:43pm UTC](https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867 "2018-04-09T16:43:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eckart-S](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/eckart-s/32/44907_2.png) [@Eckart-S](https://forum.dynamobim.com/u/Eckart-S)\
**Post date:** [April 9, 2018, 4:43pm UTC](https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867/1 "2018-04-09T16:43:38Z")

</div>

When I use my **custom** nodes (external dll - works properly in 1.3 without issues) in Dynamo 2.0, save the dyn file and reopen it the ports seem to duplicate every time?

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/6/f64ce9df8b172758b2b38d8edd472d6b71bd5f14.png)

Did someone else have this problem, too?  
Any idea what could be wrong or different in 2.0?

The code is pretty standard and looks like this:

[IsDesignScriptCompatible]  
[NodeName(“Stream”)]  
[NodeDescription(“Stream node.”)]  
[NodeCategory(“XXX.Streams”)]  
[InPortNames(“Ss”,“I”,“N”)]  
[InPortTypes(“Stream [List]”,“String [Item]”,“String [Item]”)]  
[InPortDescriptions(“Streams [List]”,“Stream ID [Item]”,“Stream Name [Item]”)]  
[OutPortNames(“S”,“Ls”,“Os”,“Ds”)]  
[OutPortTypes(“Stream [Item]”, “Layer [List]”, “Object [List]”,“Dictionary [List]”)]  
[OutPortDescriptions(“Stream [Item]”, “Layers [List]”, “Objects [List]”,“Dictionaries [List]”)]

```
public class Stream_Node : NodeModel
{
    public Stream_Node()
    {
        RegisterAllPorts();
    }

    public override IEnumerable<AssociativeNode> BuildOutputAst(List<AssociativeNode> inputAstNodes)
    {
        var functionCall = AstFactory.BuildFunctionCall(
            new Func<Stream, List<Layer>>(Receive),
            new List<AssociativeNode>() { inputAstNodes[0] });

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

}

```

Best, Eckart

---

<div class="post-metadata">

**Author:** ![Michael\_Kirschner2](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michael_kirschner2/32/75576_2.png) [@Michael\_Kirschner2](https://forum.dynamobim.com/u/Michael_Kirschner2)\
**Post date:** [April 9, 2018, 7:43pm UTC](https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867/2 "2018-04-09T19:43:39Z")

</div>

@Eckart-S when implementing a nodeModel node in Dynamo 2.0 you must write a json constructor - you can look at some of our nodeModels as a guide- we’ll be releasing some developer docs on this in the near future.

> <https://github.com/DynamoDS/Dynamo/blob/dec6240ded0c4369617775336b9af60c2aba4103/src/Libraries/CoreNodeModels/ColorRange.cs#L44>

@Racel FYI.

---

<div class="post-metadata">

**Author:** ![Eckart-S](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/eckart-s/32/44907_2.png) [@Eckart-S](https://forum.dynamobim.com/u/Eckart-S)\
**Post date:** [April 10, 2018, 12:11pm UTC](https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867/3 "2018-04-10T12:11:13Z")

</div>

Thank you very much Michael, I will have a look and try things out later.  
The dictionary features of 2.0 are really helpful for my plugin so supporting 2.0 will be the key.

Best, Eckart

---

<div class="post-metadata">

**Author:** ![Eckart-S](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/eckart-s/32/44907_2.png) [@Eckart-S](https://forum.dynamobim.com/u/Eckart-S)\
**Post date:** [April 19, 2018, 1:13pm UTC](https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867/4 "2018-04-19T13:13:24Z")

</div>

Dear @Michael_Kirschner2 & @Racel

I tried a couple different things but I don’t think the missing Json Constructor is the reason why the duplicated ports are produced for custom nodes residing in **external** dlls. Other custom nodes from different authors seem to have this issue as well, so this might be a global issue / bug?

The **internal** ColorRange node seems to work in Dynamo 2.0 but maybe this is due to the different environment, e.g. namespace, internal-only classes / parameters, etc.?

I put a VERY simple **external** custom node here that just forwards strings:

> **[Eckart-S/CustomNode](https://github.com/Eckart-S/CustomNode)**
>
> CustomNode Test for Dynamo 2.0. Contribute to Eckart-S/CustomNode development by creating an account on GitHub.

Can you have a look if you encounter the same issues (duplicating ports) with this and if you can figure out what is wrong? What could be the issue here apart from the new Json Constructor in Dynamo 2.0?

Before saving it looks like this:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/1/c1532a2e82bc2360c6d30e68dd0b6bdf2d8d0a00.png)

After saving and reopening the Dynamo file it looks like this:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/c/dc450b2a6e2d55f76903f40ce30f986b642124ab.png)

Thank you very much!  
Best regards, Eckart

---

<div class="post-metadata">

**Author:** ![Michael\_Kirschner2](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michael_kirschner2/32/75576_2.png) [@Michael\_Kirschner2](https://forum.dynamobim.com/u/Michael_Kirschner2)\
**Post date:** [April 19, 2018, 2:51pm UTC](https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867/5 "2018-04-19T14:51:36Z")

</div>

Hi @Eckart-S - I see that you are referencing a different version of [json.net](http://json.net) than dynamo does, I also see that you deliver this other version with your package. This is almost surely the problem. Likely both versions of [json.net](http://json.net) are loaded into the current app domain, and then when [json.net](http://json.net) attempts to find the [jsonConstructor] attribute it fails to find the one on your constructor method as equal.

Try either referencing an 8.0 version of [json.net](http://json.net) (I think we use 8.03) and/or do not deliver [json.net](http://json.net) with your package, it will already be loaded by dynamo.

If this is the case we will document this throughly, and thanks for trying out 2.0.

---

<div class="post-metadata">

**Author:** ![Eckart-S](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/eckart-s/32/44907_2.png) [@Eckart-S](https://forum.dynamobim.com/u/Eckart-S)\
**Post date:** [April 19, 2018, 3:22pm UTC](https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867/6 "2018-04-19T15:22:59Z")

</div>

Ah I think that solves the big mystery.  
I did a very quick test with 8.03 and it seems to work. Will try more properly later.

I think most people will just use NuGet and install the newest version of json - v8 is pretty old 🙂

Are there other requirements or recommendations regarding versions to keep in mind? E.g. which .NET version to use, etc.?

Thanks a lot for the hint Michael!

---

<div class="post-metadata">

**Author:** ![Michael\_Kirschner2](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michael_kirschner2/32/75576_2.png) [@Michael\_Kirschner2](https://forum.dynamobim.com/u/Michael_Kirschner2)\
**Post date:** [April 19, 2018, 3:37pm UTC](https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867/7 "2018-04-19T15:37:15Z")

</div>

Hi @Eckart-S we will update the docs with a version to use and hopefully we will change our nugets to include a dep on the right version so it should just work and be available when you reference dynamo nugets.

---

<div class="post-metadata">

**Author:** ![Eckart-S](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/eckart-s/32/44907_2.png) [@Eckart-S](https://forum.dynamobim.com/u/Eckart-S)\
**Post date:** [April 19, 2018, 4:05pm UTC](https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867/8 "2018-04-19T16:05:25Z")

</div>

Ok cool. Thanks a lot! 🙂

---

<div class="post-metadata">

**Author:** ![Aaron\_Tang](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/aaron_tang/32/195_2.png) [@Aaron\_Tang](https://forum.dynamobim.com/u/Aaron_Tang)\
**Post date:** [May 15, 2018, 7:52pm UTC](https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867/9 "2018-05-15T19:52:06Z")

</div>

Hi @Eckart-S This is fixed in [https://github.com/DynamoDS/Dynamo/pull/8860](https://github.com/DynamoDS/Dynamo/pull/8860), and you should be able to see it become in effect in nugets starting from 2.0.1.4955 at [https://www.nuget.org/packages/DynamoVisualProgramming.Core/2.0.1.4955](https://www.nuget.org/packages/DynamoVisualProgramming.Core/2.0.1.4955). NewtonSoft.Json should be referenced automatically for you in the future which use same version DynamoCore is depending.

Cheers

---

<div class="post-metadata">

**Author:** ![Michael684](https://avatars.discourse-cdn.com/v4/letter/m/ebca7d/32.png) [@Michael684](https://forum.dynamobim.com/u/Michael684)\
**Post date:** [July 16, 2020, 12:39pm UTC](https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867/10 "2020-07-16T12:39:04Z")

</div>

I just wanted to bump the solution for anyone experiencing the multiple output ports problem.

**I can now also confirm that ‘downgrading’ to Newtonsoft Json version 8.03 worked!**

Hope this helps someone.

Michael

---

<div class="post-metadata">

**Author:** ![olliegreen](https://avatars.discourse-cdn.com/v4/letter/o/f17d59/32.png) [@olliegreen](https://forum.dynamobim.com/u/olliegreen)\
**Post date:** [June 1, 2021, 2:13pm UTC](https://forum.dynamobim.com/t/dynamo-2-0-duplicates-ports-of-custom-node-when-file-is-saved-and-reopened/20867/11 "2021-06-01T14:13:35Z")

</div>

Similar problem encountered here - turns out Visual Studio was interpreting the [JSONConstructor] attribute as belonging to System.Text.JSON, not Newtonsoft.
