I hope you find it useful. Right now instantiate className only handles simple Classes with no constructor arguments.
other features I’ve been challenged to add are :
- Create instance with parameters.
- Invoke a method or property on a static class.
1.) is Harder than I thought, if I must avoid the use of dotNetObject when initiating.
My C# test class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyNameSpace
{
public class MyClassWithArg
{
public string arg;
public MyClassWithArg(string thisArg)
{
arg = thisArg;
}
public string sayArg()
{
return ("MyClassWithArg.sayArg has been called.
MyClassWithArg.arg = " + arg + ".
");
}
}
}
It’s easy enough to call with an argument using this MXS
MyClassWithArgs=dotNetObject "MyNameSpace.MyClassWithArg" "hello, world"
but this gives an error
MyClassWithArgs=dllManager.assembly.CreateInstance "MyNameSpace.MyClassWithArg" "hello,world"
-- Runtime error: No method found which matched argument list
as does converting the argument into a System.Object[] dotnet value:
dotNetArg=dotNet.ValueToDotNetObject #("hello,world") (dotNetObject "System.Object")
MyClassWithArgs=dllManager.assembly.CreateInstance "MyNameSpace.MyClassWithArg" dotNetArg
-- Runtime error: No method found which matched argument list
It seems to be an issue in properly passing the arguments to the constructor.
Anyone have insight?