From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-13-2021 04:17 AM
My colleague told me that the .net DLL attached has a function named reglogin(). But I never find it. I don not know why? Anyone can help?
Solved! Go to Solution.
04-13-2021 06:40 AM
It would help if he told you which object had this function. There are quite a lot of objects in the assembly. Each object probably has multiple functions...
There's a regLogin function in com.itac.mes.imsapi.client.dotnet.IIMSApiDotNet and one in com.itac.mes.imsapi.client.dotnet.IMSApiDotNet.
However, both objects are not creatable with a constructor node. So, you'd need instructions on how to use the assembly.
This tree should have all function in the hierarchy:
Also attached as VI.
That was a lot of work, typing all those tree items 😉!
04-14-2021 08:11 PM
I decompiled that assembly (luckily its not obfuscated). Using the starting point indicated by wiebe@CARYA, I decompiled the IMSApiDotNet class.
It look like this class implements the Singleton pattern. In order to obtain the (single) instance of the class, you need to call the "loadLibrary()" method, which returns the single instance. Like other implementations of Singleton, the single instance is stashed in the single created type class (static) so its only created once. You could then attempt to call the method you're after.
04-15-2021 08:11 PM
Thank you, wiebe. Actually, I've got some instructions from the DLL creator. Like this:
regLogin() Started: Mon Apr 12 15:22:16 CST 2021 Input values: sessionValidationStruct.class=com.itac.mes.imsapi.domain.container.IMSApiSessionValidationStruct sessionValidationStruct.stationNumber=S06OBC01-00010-01
sessionValidationStruct.stationPassword=-1
sessionValidationStruct.user=USER
sessionValidationStruct.password=PASSWORD
sessionValidationStruct.client=01
sessionValidationStruct.registrationType=-1
sessionValidationStruct.systemIdentifier=-1
Finished in: 109 ms ------------------------------------------------------------------
Result_regLogin
.return_value=0 ''
.sessionContext.class=com.itac.mes.imsapi.domain.container.IMSApiSessionContextStruct .sessionContext.sessionId=7,275,984,213,731,947,329
.sessionContext.persId=58
.sessionContext.locale=en_US
I want to know how to implement this function using LabVIEW. Can you give me some suggestions?
04-16-2021 03:27 AM
That looks like a log of an execution, not actual code.
I'd start with creating a constant of the type. Even though you'd normally create an object with a constructor, this object doesn't have a constructor. It might be static, or have static methods or properties that facilitate it's creation. A constant doesn't create the object, but wired to a property node or invoke node does show it's functions. Static properties and methods will usually work.
I'd also look into the LoadLibrary function.
04-16-2021 03:39 AM
LoadLibrary is indeed static...
And don't change the constant's class when wired to a node. That will crash LabVIEW.
06-15-2021 05:00 AM
Hello wiebe
I have two issues:
1. My LabVIEW is 2017 and I cannot open your VI;
2. Since we can not using the DLL with a constructor node, how do I use it to obtain these functions in the tree?
Thank you.
06-15-2021 05:36 AM - edited 06-15-2021 06:03 AM
loadLibrary() is a static method of your assembly. You simply configure an Invoke Node in LabVIEW to connect to this class (right clicking on the Node and selecting "Select Class->.Net->Browse), or create a .Net refnum control or constant that is configured to be this class and connect it to the invoke node, and then call it. There is no need and no way to "construct" this object, you simply call it directly, since the static loadLibrary() method does this internally when first called.
It will either return an error (which your friend will have to help you with if that happens as we have not seen any documentation or whatsoever about this library), or it returns an object instance that you can then use further.
That's all there is to static methods (and properties) in an assembly.
Your friend should have given you some real source code which would probably have looked similar to this:
IMSApiSessionValidationStruct imsValidation = new IMSApiSessionValidationStruct(stationNumber, stationPassword, user, password, client, registrationType, systemIdentifier);
IMSApiDotNet imsAPI = IMSApiDotNet.loadLibrary();
imsAPI.regLogin(imsValidation);
The "new" keyword is synonymous to the LabVIEW .Net Constructor node. For the IMSApiDotNet object you do not have any new keyword but simply call the static loadLibrary() method of the IMSApiDotNet class to get an instance to the internally created class. That it is a singleton is an internal detail that should not concern you at all, how to obtain that object however is something that should be documented in the hopefully existing documentation for this assembly.
If it isn't documented, or even worse that documentation doesn't exist, you should whack your friend around his ears for this. 😀
And you shouldn't forget to call the LabVIEW CloseReference node on these two refnums (and any others you may create or get returned to by API functions) after you are done with them. You called a (static) method that returned you an object. You should then dispose that object when you are done with it, that it was returned by a static method has no further meaning for the object it returned.
06-15-2021 06:14 AM
@GrayJoker wrote:
Hello wiebe
I have two issues:
1. My LabVIEW is 2017 and I cannot open your VI;
2. Since we can not using the DLL with a constructor node, how do I use it to obtain these functions in the tree?
Attached is the VI in LV17.
06-18-2021 02:33 AM
Thank you.