07-24-2012 04:39 AM
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#.
Solved! Go to Solution.
07-24-2012 04:45 AM
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?
07-24-2012 05:13 AM
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#.
07-24-2012 05:43 AM
07-24-2012 06:39 AM
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
07-24-2012 09:46 AM
@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.
07-30-2012 02:01 AM
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)??
07-30-2012 04:34 AM
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!
07-30-2012 04:55 AM
Yes,labview server is listening to the same port as client tries to connect.
Please see the attachments.
07-30-2012 05:41 AM - edited 07-30-2012 05:43 AM
@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.