Forum

Errors with init ManualDynamicEnum at startup

Hi.
I use ManualDynamicEnum.
When i open patch i’ve got an error on node that use this enum.
image
InitDeviceMap - initialise this enum and it’s assign on Create.


but if i open GetMute node, error disappeared.
What’s best way to init generic enums for work without errors on startup?

did you make your own C# class that uses this as base class? like it is described here:

https://vvvv.gitbooks.io/the-gray-book/content/en/reference/libraries/writing-nodes.html

yes.
using System;
using VL.Lib.Collections;

namespace NanoKontrolEnum
{
    public class DeviceMapEnumDefenition : ManualDynamicEnumDefinitionBase<DeviceMapEnumDefenition>
    {
        public static DeviceMapEnumDefenition Instance => ManualDynamicEnumDefinitionBase<DeviceMapEnumDefenition>.Instance;

        override protected bool AutoSortAlphabetically => false;
    }

    [Serializable]
    public class DeviceMapEnum : DynamicEnumBase<DeviceMapEnum, DeviceMapEnumDefenition>
    {
        public DeviceMapEnum(string value) : base(value)
        {
        }

        //this method needs to be imported in VL to set the default
        public static DeviceMapEnum CreateDefault()
        {
            //use method of base class if nothing special required
            return CreateDefaultBase();
        }
    }
}

that’s code of it


Here code of lib with that enum

None of your patches get executed, you placed them all in the document definition patch, so even the constructor of your KorgMidi node will never run and subsequently those enums will never get registered.
A better way to go about it is making use of the RegisterServices operation which gets executed (if present) for each document. Something like this:

image

I used it as library in

So I register enum from there.
I try with RegisterSevice in lib but same result.