LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass string from labview to c#

Hi
I have used .net assembly to use a dll in c#.
The communication part is fine and I can pass the parameters from c# to labview but one of the functions should read back a string from labview

WriteSingle(string in, out string);

And I see nothing goes back to c# . Could you please help me with this . How should I pass the string in LabVIEW that can be recognised in c#

Thanks
0 Kudos
Message 1 of 6
(3,507 Views)

I would greatly appreciate any help

0 Kudos
Message 2 of 6
(3,480 Views)

Have you done a search or gone through this?

White Paper on DLL access

 

Can you post how you've configured your Call Function Node?

0 Kudos
Message 3 of 6
(3,474 Views)

I assume that you mean that you have compiled your LabVIEW code into a DLL, which contains functions that you are calling from C#. You need to allocate the output string in the C# code before you call the DLL. LabVIEW will not allocate a new string, it will simply use the space provided to it. If you pass a zero-length string, then what you get back will also be a zero-length string. I don't know enough C# to tell you how to do this allocation, but I'm pretty sure others have asked the same question on this forum and some searching might turn up the answer.

0 Kudos
Message 4 of 6
(3,468 Views)

let me explain it step by step

 

1. I made a dll using .NET assembly

2. I added the dll to the references in c# and here is the difinition for it 

public static void singleRead(out int element)

 

3. Then I call the function as below : 

 

int m;
singleRead(out m);

 

format of element is I32 in LabVIEW and everything completely matches but I can't read data back from LabVIEW to c#. so when I run the code m is zero

 

I can completely communciate through that dll from c# to labVIEW and I can send parameters as input from c# to labVIEW but for the other way seems like something is missing and I can't read it back 

 

I forgot to mentiond I changed my output from string to I32 because I thought it might fix the problem but I still se the issue

0 Kudos
Message 5 of 6
(3,457 Views)

How did you configure the VI parameters when you built the .NET assembly? A screenshot or two would help. Any parameters that will contain new values when they return need to be passed by reference, not by value.

0 Kudos
Message 6 of 6
(3,442 Views)