Delegate does not contain a definition for 'CreateDelegate'

file included if text cannot be interpreted[98338-superstatemachine.txt|98338]

I am trying to export my game to UWP, but every attempt, I get this error

‘Delegate’ does not contain a definition for ‘CreateDelegate’
I am using the .NET scripting backend, and have read that issues can arise from it with this sort of thing?

Any ideas on how to fix this?

Code:

*using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;

public class SuperStateMachine : MonoBehaviour {

    protected float timeEnteredState;

    public class State
    {
        public Action DoSuperUpdate = DoNothing;
        public Action enterState = DoNothing;
        public Action exitState = DoNothing;

        public Enum currentState;
    }

    public State state = new State();

    public Enum currentState
    {
        get
        {
            return state.currentState;
        }
        set
        {
            if (state.currentState == value)
                return;

            ChangingState();
            state.currentState = value;
            ConfigureCurrentState();
        }
    }

    [HideInInspector]
    public Enum lastState;

    void ChangingState()
    {
        lastState = state.currentState;
        timeEnteredState = Time.time;
    }

    void ConfigureCurrentState()
    {
        if (state.exitState != null)
        {
            state.exitState();
        }

        //Now we need to configure all of the methods
        state.DoSuperUpdate = ConfigureDelegate<Action>("SuperUpdate", DoNothing);
        state.enterState = ConfigureDelegate<Action>("EnterState", DoNothing);
        state.exitState = ConfigureDelegate<Action>("ExitState", DoNothing);

        if (state.enterState != null)
        {
            state.enterState();
        }
    }

    Dictionary<Enum, Dictionary<string, Delegate>> _cache = new Dictionary<Enum, Dictionary<string, Delegate>>();

    T ConfigureDelegate<T>(string methodRoot, T Default) where T : class
    {

        Dictionary<string, Delegate> lookup;
        if (!_cache.TryGetValue(state.currentState, out lookup))
        {
            _cache[state.currentState] = lookup = new Dictionary<string, Delegate>();
        }
        Delegate returnValue;
        if (!lookup.TryGetValue(methodRoot, out returnValue))
        {
            var mtd = GetType().GetMethod(state.currentState.ToString() + "_" + methodRoot, BindingFlags.Instance
                | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod);

            if (mtd != null)
            {
                returnValue = Delegate.CreateDelegate(typeof(T), this, mtd);
            }
            else
            {
                returnValue = Default as Delegate;
            }
            lookup[methodRoot] = returnValue;
        }
        return returnValue as T;

    }

    void SuperUpdate()
    {
        EarlyGlobalSuperUpdate();

        state.DoSuperUpdate();

        LateGlobalSuperUpdate();
    }

    protected void DelegateMethod(string method, object[] parameters)
    {
        var mtd = GetType().GetMethod(state.currentState.ToString() + "_" + method, BindingFlags.Instance | BindingFlags.NonPublic);

        if (mtd == null)
        {
            mtd = GetType().GetMethod("Global" + "_" + method, BindingFlags.Instance | BindingFlags.NonPublic);
        }

        mtd.Invoke(this, parameters);
    }

    protected virtual void EarlyGlobalSuperUpdate() { }

    protected virtual void LateGlobalSuperUpdate() { }

    static void DoNothing() { }
}*

tried multiple times to get code to display properly, but it keeps showing up like this

Delegate.CreateDelegate()

Is not available on UWP platforms. You’ll need to use

methidInfo.CreateDelegate(..)

UWP subset of .NET is tricky and will cause a lot of trouble. Try going with IL2CPP scripting backend, as far as I know it’s available on UWP platform now.

Source - c# - Why can't I call Delegate.CreateDelegate in my Portable Class Library? - Stack Overflow