I see some older threads discussing some in-progress ideas people were working with, as well as some libraries on the nuget packages out there - but there is no documentation on them that I can see. Does anyone have a recommended usage for them? Have any libraries been made? It seems like it should be possible to instantiate Sage methods natively, rather than needing to write a string to pass to the object so that we could do things like pvx.Init("PATH")
verses pvx.GetType().InvokeMember("Init", System.Reflection.BindingFlags.InvokeMethod, null, pvx, new object[] { @"\\server\Apps\Sage100_2018\MAS90" });
That said, at least a lot of that noise can be shortened with this method, but it still leaves open the possibility of typos in whatever function you're calling:
static object GetInvoke(string method, object[]? newObject = null)
{
if (newObject == null)
{
return oSS.GetType().InvokeMember(method, System.Reflection.BindingFlags.InvokeMethod, null, oSS, null);
}
else
{
return oSS.GetType().InvokeMember(method, System.Reflection.BindingFlags.InvokeMethod, null, oSS, newObject);
}
}
//called like: (int)GetInvoke("nSetCompany", new object[] { "TST", 1 })