From Friday, January 17th 11 PM CDT (January 18th 5 AM UTC) through Saturday, January 18th 11:30 AM CDT (January 18th 5:30 PM UTC), ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Interface between LabVIEW and C#

Solved!
Go to solution

Hi,

      Iam trying to send some data from Labview through ithernet into a product that have already done in C# .net.That means data send from LabVIEW have to be displayed in C#.Thus the Labview will act as the server and the product in C# will act act as the client.I serached in the forums for establishing connection between Labview and C#.I saw one tutorial for making dlls in labview,In that they have explained to take from Tools>>Build Application or shared Library.But I can't found it in my Tools Although I have professional development version2009.

 

Can anybody give me some instructions to send data from Labview and display it in C#.Iam attaching the server VI that I have made.The client in C# is a bigger product that already done by other in C#.I have very less programming experience in C#.Can anybody give me some instructions or attaching some tutorials for establishing connection between Labview and C#.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
0 Kudos
Message 1 of 36
(10,658 Views)

Hi danil,

 

- don't attach files with forbidden/problematic chars in their name

- your problem has nothing to do with connecting LV and C#

- it's just a problem of using a TCP connection

- why do you open a TCP listener and then try to write to that port?

 

There are examples on TCP communication coming with your LabVIEW installation. Found them?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 36
(10,646 Views)

Hi GerdW,

                     TCP communication coming with  LabVIEW installation, that I have seen and I can easily send that data to a client made in labview.Iam trying to establish a connection with C#.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
0 Kudos
Message 3 of 36
(10,638 Views)

Hi danil,

 

no you don't communicate with some "C#". You communicate with a different pc/program!

Both ends of that communication have to use the same protocol.

Does your other program (written in C#) apply to that?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 36
(10,633 Views)

DLL's are for using C# code within a LV program, that's not what you're doing. 

You are communicating with TCP/IP over a protocol, basic, C#, LV or Cobol is irrelevant, send data in the expected format, just like HTML is the same regardless of OS and browser.

/Y 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 5 of 36
(10,624 Views)

@Yamaeda wrote:

DLL's are for using C# code within a LV program, that's not what you're doing. 



Actually DLLs are strictly speaking normally shared libraries exporting standard C functions. They get interfaced with the Call Library Node. .Net libraries (written in C#, VB or whatever) are normally called assemblies, although the are usually packaged in a file with a DLL extension, but they are VERY different from normal shared libraries.To access .Net assemblies you use the .Net Nodes in LabVIEW. In LabVIEW you can create normal DLLs or .Net assemblies from VIs.

 

It's probably possible with some involved magic to write normal DLLs in C# but most likely a pain in the ass and a quite useless exercise. And if you want to call a normal DLL from C# you have to use unmanaged interface, which is also a pain in the ass, since you have to worry about the same things as when you use the Call Library Node to interface to a DLL.

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 36
(10,606 Views)

Thanks for the comments.Through TCP we can send the data.But I can't establish the connection between the two.Originally we have two C# applications.One for sending the data(server) and another for receiving the data(client).We are trying to replace the "server" with our labview application.In the C# client application there is a built-in class on_client receive() for receiving the data from the C# server.While using our labview application instead of C# server,It is showing that connection is not established.

 

Can anyone attach some simple example in which labview acts as server(for sending data) and a C# application acts as client(for receiving that data)?? 

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
0 Kudos
Message 7 of 36
(10,556 Views)

Are you sure your LabVIEW server listens on the same port as the client tries to connect too?

Can you instead provide the (stripped down) C# code of your server and the LabVIEW code you try to replace this server with instead of asking us to show you an example of how to do it? That would be awfully more easy to look at your code and point out where you go wrong, than creating an example here first!

Rolf Kalbermatter
My Blog
0 Kudos
Message 8 of 36
(10,544 Views)

Yes,labview server is listening to the same port as client tries to connect.

Please see the attachments.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thanks as kudos only:)
Download All
0 Kudos
Message 9 of 36
(10,537 Views)

@danil33 wrote:

Yes,labview server is listening to the same port as client tries to connect.


And why would the LabVIEW Server (not a client as the VI name suggests) use port 8222 while the C# code uses port number 8221?

And the C# code as well as the LabVIEW server only write to the socket, so you won't see much happening there as the actual other side is never reading at all anything written to the stream.

Rolf Kalbermatter
My Blog
0 Kudos
Message 10 of 36
(10,530 Views)