cancel
Showing results for 
Search instead for 
Did you mean: 

VbScript CreateObject replacement in UNity

Ray_Muenzer
Champ on-the-rise
Champ on-the-rise

I'm converting from VbScript in OnBase 18 to a potential upgrade to Unity under EP3 or EP5.  In a number of VbScripts, i rely on a very custom DLL (written in VB.Net) that has a number of entry points.  Each entry point displays a custom data entry screen which also displays data from numerous databases outside of OnBase.

 

Each call to the DLL looks similar to:

Set objghijklDLL = CreateObject("abcdef.ghijkl")
iDLLReturn = objghijklDLL.LoadForm(lngDocHandle, kwcode1, kwcode2, kwcode3, DLL_DSN)

 

I've searched both the SDK and on Community, and I haven't found any comparable calls or work arounds for this.

 

Any suggestions and/or advise would be appreciated.

2 ACCEPTED ANSWERS

Derick_Geisend2
Champ on-the-rise
Champ on-the-rise

maybe something like this might work?

(shamelessly stolen from:  https://stackoverflow.com/questions/11886845/dynamically-calling-a-dll-and-method-with-arguments )

   

public void callDLL(string dllName, string typeName, string methodName, string arguments) {	string[] argumentArray = arguments.Split(',').trim();    Assembly assembly = Assembly.LoadFrom(dllName);    System.Type type = assembly.GetType(typeName);    Object o = Activator.CreateInstance(type);    MethodInfo method = type.GetMethod(methodName);    ParameterInfo[] parameters = method.GetParameters();    object[] methodParameters = new object[parameters.GetLength(0)];    for (int i = 0; i < parameters.Length; i++)    {        var converter = TypeDescriptor.GetConverter(parameters.ParameterType());        methodParameters = converter.ConvertFrom(argumentArray);    }    method.Invoke(o, methodParameters); }dynamic iDllReturn = callDLL("abcdef", "ghijkl", "LoadForm", "lngDocHandle, kwcode1, kwcode2, kwcode3, DLL_DSN");

 

View answer in original post

Ray_Muenzer
Champ on-the-rise
Champ on-the-rise

Well, i dug deeper into the SDK and determined that modifying my DLL slightly and adding it as an Assembly, then creating a new IClientWorkflowScript, allowed it to call the class in the dll and execute it properly.

Added reference to assembly to unity script

then the basic code(VB.NET):

DIM abc as NEW avcdef,fhijkl

abc.loadform(dochandle,kwcode1,kwcode2,kwcode3,DLL_DSN)

 

Very sparse at the moment, but functionally it calls the DLL...Now, this will only work in the Unity Client...the Web Client would require something more ambitious and beyond the scope of what i need to do.

View answer in original post

3 REPLIES 3

Derick_Geisend2
Champ on-the-rise
Champ on-the-rise

maybe something like this might work?

(shamelessly stolen from:  https://stackoverflow.com/questions/11886845/dynamically-calling-a-dll-and-method-with-arguments )

   

public void callDLL(string dllName, string typeName, string methodName, string arguments) {	string[] argumentArray = arguments.Split(',').trim();    Assembly assembly = Assembly.LoadFrom(dllName);    System.Type type = assembly.GetType(typeName);    Object o = Activator.CreateInstance(type);    MethodInfo method = type.GetMethod(methodName);    ParameterInfo[] parameters = method.GetParameters();    object[] methodParameters = new object[parameters.GetLength(0)];    for (int i = 0; i < parameters.Length; i++)    {        var converter = TypeDescriptor.GetConverter(parameters.ParameterType());        methodParameters = converter.ConvertFrom(argumentArray);    }    method.Invoke(o, methodParameters); }dynamic iDllReturn = callDLL("abcdef", "ghijkl", "LoadForm", "lngDocHandle, kwcode1, kwcode2, kwcode3, DLL_DSN");

 

Thank you

Ray_Muenzer
Champ on-the-rise
Champ on-the-rise

Well, i dug deeper into the SDK and determined that modifying my DLL slightly and adding it as an Assembly, then creating a new IClientWorkflowScript, allowed it to call the class in the dll and execute it properly.

Added reference to assembly to unity script

then the basic code(VB.NET):

DIM abc as NEW avcdef,fhijkl

abc.loadform(dochandle,kwcode1,kwcode2,kwcode3,DLL_DSN)

 

Very sparse at the moment, but functionally it calls the DLL...Now, this will only work in the Unity Client...the Web Client would require something more ambitious and beyond the scope of what i need to do.