Showing results for 
Search instead for 
Did you mean: 

Not find a function in a .net DLL

Go to solution

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?

0 Kudos
Message 1 of 10
Accepted by topic author GrayJoker

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:

regLogin Tree.png


Also attached as VI.


That was a lot of work, typing all those tree items 😉!

0 Kudos
Message 2 of 10

I decompiled that assembly (luckily its not obfuscated). Using the starting point



Message 3 of 10

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







Finished in: 109 ms ------------------------------------------------------------------


.return_value=0 ''

.sessionContext.class=com.itac.mes.imsapi.domain.container.IMSApiSessionContextStruct .sessionContext.sessionId=7,275,984,213,731,947,329




I want to know how to implement this function using LabVIEW. Can you give me some suggestions?

0 Kudos
Message 4 of 10

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.

0 Kudos
Message 5 of 10

LoadLibrary is indeed static...


And don't change the constant's class when wired to a node. That will crash LabVIEW.


regLogin code.png

0 Kudos
Message 6 of 10



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.

0 Kudos
Message 7 of 10
Accepted by topic author GrayJoker

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();


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. 

Rolf Kalbermatter
Averna BV
0 Kudos
Message 8 of 10
Accepted by topic author GrayJoker

@GrayJoker wrote:



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.

0 Kudos
Message 9 of 10

Thank you.

Message 10 of 10