Right, that won't work, assuming your code is as you posted it earlier.
If
Now you can expose a delegate that invokes the static method:
By the way, if
If
me
represents a static method, first declare an appropriate delegate type:publicdelegateobject StaticMethodFunc(paramsobject[] args);
engine.AddHostObject(me.Name, new StaticMethodFunc(args => me.Invoke(null, args)));
me
represents an instance method, you can still expose a delegate that doesn't require an explicit target. All you have to do is provide the target in advance:var target = Activator.CreateInstance(t); // or create the target some other way engine.AddHostObject(me.Name, new StaticMethodFunc(args => me.Invoke(target, args)));