Adding UserData in GH

Hi guys,

I am trying to add a custom object-type via UserData.add(…) to Geometry Objects using the C#-component. I m currently writing gh components which do an “equivalent” job as a rhino plugIn (which is already there), that uses UserData already. The PlugIn orientates on this
and I was wondering whether the same idea works also within gh. I tried UserString & UserDictionary which is working fine, but this would mean some enormous workaround in the existing code (of the plugIn) which I m trying to avoid…

I got this helpful example (…) but its just not working out for me and I woudl like to understand the reason. I am always getting “Object reference not set to an instance of an object”.

The Class which is storing the UserData looks like this. Its built in VS and referenced as .dll into the scripting component:

 public class MeshUserData : Rhino.DocObjects.Custom.UserData
     public List<double> meshResults; 

     public MeshUserData()
          meshResults = new List<double>();

I attached the .gh (I cant provide the .dll here) which I am using. Many thanks for any help or hints I could get on understanding the problem and reason behind this Error and making it work!! (2.2 KB)