Question Thembelani Mlalazi · Feb 28

Net Gateway How to instantiate a Class with a Constructor with a parameter

I have been trying to get to grips with the new dot Net Gateway used in IRIS as the import of the DLL to construct proxy classes is no longer supported in IRIS I have a third party DLL that when I try to instantiate throws an error complaining about the class not instantiated as it does not support parameterless constructor .I am using this new 

set gateway = $system.external.getDotNetGateway()
do gateway.addToPath(myPath_"\DotNetGatewaySamples.dll")

 

I would like then to instantiate my class which has a constructor that requires a parameter, how am I suppose to achieve that and if there is a documentation that explains this in depth that I missed please direct me to it thank you. This is what I have tried and it compiles with errors

set remoteObj=gateway.new("parametisedClass(theparameter)")
Product version: IRIS 2024.2
$ZV: IRIS for Windows (x86-64) 2024.1 (Build 267_2U)

Comments

Thembelani Mlalazi  Feb 28 to Enrico Parisi

 @Enrico Parisi 
I have tried calling it that I get

<THROW>%Constructor+33^%Net.Remote.Object.1 *%Net.Remote.Exception <GATEWAY> System.Reflection.TargetInvocationException  Exception has been thrown by the target of an invocation.
0
Enrico Parisi  Feb 28 to Thembelani Mlalazi

Are you sure you are using the correct/full name reference to your parametisedClass?

It should be NamespaceName.PublicClassName

0
Enrico Parisi  Feb 28 to Thembelani Mlalazi

You can enable the log in the .NET Gateway and see if the log give you some useful info.

As in my previous post, my guess is that you are passing the wrong/incomplete class name as 1st parameter of new().

0