Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling .NET module from LabVIEW

Hi, 

I'm a beginner of LabVIEW.  

I straggled with calling .NET module from LabVIEW, but I couldn't.  I just wired create instance->method invoke->complete and the code became executable, but an error occurred when the wired program was executed.  (The module returned "E_FAIL")

I would like to call COM interfaces inside the module, but is it possible to call them?  I also tried to call COM interfaces directly inside the module by using "Library Function Calling Node", but I couldn't find the interfaces in the list of methods.  

I look forward to your reply.  

Thanks,

Hideki

0 Kudos
Message 1 of 5
(2,945 Views)

Hello yamahide!

The Library Function Call Node is used to call "normal" DLL files.

The more modern, object-oriented .NET assemblies (with the same file extension though), are used with the way I think you described. Use the .NET Constructor Node, then use e.g. Invoke Nodes.

 

See e.g. DLL Functions Unavailable to Be Selected on Call Library Function or Example Program: Calling .NET Assemblies From LabVIEW for more information.

 

However, it's impossible to tell what the exact issue with your code it. Can you post your LabVIEW VI here? If possible, please save it in an older file format (LV 2014 is good) so more people can open it. When you have the VI open, go to menu File » Save for Previous Version.


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 2 of 5
(2,912 Views)

Thanks for your reply!

 

I also really appreciated for you information that the node can only call 'normal' dll.  

 

I also had already tried if I could call the interfaces by using method invoke of .NET control.  

 

Unfortunately, I only had LabVIEW 2018 and my evaluation licence has been expired.  

I attach the VI file of new version, but I'm not sure if it is useful.  

 

Many thanks,

yamahide 

0 Kudos
Message 3 of 5
(2,909 Views)

Hello Hideki,

 

Thank you very much for your quick reply and the attached VI. I believe it was useful, as I can confirm you set up up the same way I would do. So I'd assume the issue is not with your LabVIEW programming, but:

  • either within the way how the DLL is used. Currently you are creating the .NET object, and then using an Invoke node to call a function inside. This seems to raise the error message, it's coming from inside the DLL. Do you have documentation on how the .NET assembly's functions have to be used? It seems like you either compiled it yourself, or got it from another company, so there is a good chance that you have some user guide or even the source code itself.
  • or there is an incompatibility caused by how data needs to be converted when passed from LabVIEW to the .NET assembly. Depending on what data types are passed, there might be need to convert from the LabVIEW data types to the appropriate C# ones manually (I found your other thread on this topic, and google translate helped me to understand that it's C# (-: )

Do you have a working piece of code in e.g. C# that successfully calls this DLL? That would e a great start to know that it generally works, and also a good code example on how it should be used. Maybe you can work from there? If that does not exist, documentation or testing (trial&error) could help.


Ingo – LabVIEW 2013, 2014, 2015, 2016, 2017, 2018, NXG 2.0, 2.1, 3.0
CLADMSD
0 Kudos
Message 4 of 5
(2,905 Views)

Thanks for your reply.  

I created the module, so I know everything about the module actually.  

Sorry, I can't provide the C# module which can call the interfaces properly.  

However, your information was very useful and I really appreciated for it.  

Many Thanks, 

Hideki

0 Kudos
Message 5 of 5
(2,901 Views)