LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I get some undesired character by passing String from Labview to C# dll

Highlighted
Hi,
 
I wrote a function in a C#-dll which I call from Labview. The parameter is a String. The dll works fine, call the function from LabVIEW too. But when I pass then following String "°C", I get the following String in my function "°C".Smiley Sad
 
I seem to be a conversion problem between LabVIEW and C', but I can't find a solution.
 
Regards,
Risotto
0 Kudos
Message 1 of 6
(797 Views)
Can you post the function declaration and the passing method you configured for the string?

Paolo
Paolo
-------------------
LV 7.1, 2011, 2017, 2019
0 Kudos
Message 2 of 6
(780 Views)
Paolo,
 
The function is:
  public int WriteLine(String str)
  {
   String s = str;
   buffer.Add(s);
   return 0;
  }
 
VI, please see attached file.
I first create an instance of an FileWriter .NET object with "File.OpenFileWriter.vi" and put the reference in a shared variable.
Then, I call the VI "_File.WriteLine (String).vi" to pass the string to the instance. At this point, the String is "°C".
 
When the data arrives in the function WriteLine, the value of str is "°C".
 
Risotto
0 Kudos
Message 3 of 6
(770 Views)
Paolo,
 
Another time with the VI.....
 
 
 
The function is:
  public int WriteLine(String str)
  {
   String s = str;
   buffer.Add(s);
   return 0;
  }
 
VI, please see attached file.
I first create an instance of an FileWriter .NET object with "File.OpenFileWriter.vi" and put the reference in a shared variable.
Then, I call the VI "_File.WriteLine (String).vi" to pass the string to the instance. At this point, the String is "°C".
 
When the data arrives in the function WriteLine, the value of str is "°C".
 
Risotto
0 Kudos
Message 4 of 6
(767 Views)
Paolo,
 
The function is:
  public int WriteLine(String str)
  {
   String s = str;
   buffer.Add(s);
   return 0;
  }
 
VI, please see attached file.
I first create an instance of an FileWriter .NET object with "File.OpenFileWriter.vi" and put the reference in a shared variable.
Then, I call the VI "_File.WriteLine (String).vi" to pass the string to the instance. At this point, the String is "°C".
 
When the data arrives in the function WriteLine, the value of str is "°C".
 
Risotto
0 Kudos
Message 5 of 6
(767 Views)
I tried to reproduce your problem, but so far I can't. Please tell me
 
1. What version of LV are you using?
2. What version of .NET are you using?
3. What language are you running? Do you know which codepage your system is set to?
4. Can you post a simple, complete example? A simple .NET dll that just takes a string and returns it, and a string control with the default value set to the problem string?
 
I did #4 myself, and copied the string off the webpage, but the actual character value might have changed going from your system, to HTML, to my system, so putting it into the VI is the best option.
0 Kudos
Message 6 of 6
(757 Views)