agmuntianu
13 years agoOccasional Contributor
Unable to retrieve a value from a .Net function via a ref parameter
Hi everyone,
I am confronted by a issue of retrieving values returned as references by a .Net assembly function:
I have a function within an .Net assembly which takes several parameters , one of which is a ref System.Byte, and returns a Boolean to indicate success of the function.
I need to retrieve the System.Byte value via the ref parameter, and it seems I cannot.
I have tried to define the variable in which I would like to get the result in multiple ways (mostly as objects) , and nothing seems to work.
Here is how my JScript script looks like :
function GetInverterVariantDLL()
{
var session;
var address;
var param;
var inverterVariant=dotNET.System.Byte();
inverterVariant=1;
session=dotNET.Danfoss_Inverter_Communication_ComLynx.ComLynxConnection.zctor_2("COM4");
address=dotNET.Danfoss_Inverter_Communication_ComLynx.ComLynxAddress.zctor_3(1,2,3);
session.Open();
param=dotNET.Danfoss_Inverter_Communication_ComLynx.Parameter.zctor(session);
var success=param.TryGetValue(address,8,30,40,inverterVariant,100);
Log.Message("variant "+inverterVariant); //It should return 2 , instead returns 1
Log.Message("success "+success);
session.Close();
}
Thank you in advance for any suggestions.
BR. Andrei.
I am confronted by a issue of retrieving values returned as references by a .Net assembly function:
I have a function within an .Net assembly which takes several parameters , one of which is a ref System.Byte, and returns a Boolean to indicate success of the function.
I need to retrieve the System.Byte value via the ref parameter, and it seems I cannot.
I have tried to define the variable in which I would like to get the result in multiple ways (mostly as objects) , and nothing seems to work.
Here is how my JScript script looks like :
function GetInverterVariantDLL()
{
var session;
var address;
var param;
var inverterVariant=dotNET.System.Byte();
inverterVariant=1;
session=dotNET.Danfoss_Inverter_Communication_ComLynx.ComLynxConnection.zctor_2("COM4");
address=dotNET.Danfoss_Inverter_Communication_ComLynx.ComLynxAddress.zctor_3(1,2,3);
session.Open();
param=dotNET.Danfoss_Inverter_Communication_ComLynx.Parameter.zctor(session);
var success=param.TryGetValue(address,8,30,40,inverterVariant,100);
Log.Message("variant "+inverterVariant); //It should return 2 , instead returns 1
Log.Message("success "+success);
session.Close();
}
Thank you in advance for any suggestions.
BR. Andrei.