11-15-2011 02:32 PM
Hello, I just started using LabView few weeks ago. I made a vi that takes data from HH506R (thermometer) through RS-232. Now I am trying to use the dll in C#. Everytime I run the C# program, I get "0" which is incorrect. I have attached the labview and c# files. Thanks.
11-18-2011 12:25 PM
Hello wakka321,
After I ran your code, I also received a value of zero, but without any hardware. After looking at your code, the problem may lie with how you are passing values by reference in C#. Please refer to the following article for help on the topic.
ref (C# Reference)
http://msdn.microsoft.com/en-us/library/14akc2c7.aspx
11-18-2011 01:08 PM - edited 11-18-2011 01:08 PM
Hello again wakka321,
Upon a second glance, I noticed a few other things wrong with this project. You're currently using the .NET framework version 4.0 with this project, which is not supported. You will want to create a new project in .NET 3.5. If you use .NET 4.0, you will likely encounter the following error:
VIAssemblyException "Failed to call InitLVClient function."
As well, the interop assembly is the .net equivalent of a C-dll file. You will want to create an interop assembly and follow the instructions at the link below to do so.
Building a .NET Interop Assembly (Windows)
http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/building_a_net_assembly/
11-18-2011 01:42 PM
Hello Shawn,
Thanks for helping. I tried changing my project to .NET 3.5 and still did not work. Anyways, my application works now. I just took some VIs out, and my application works fine. I still do not know what was wrong. Again, thanks for helping.
03-20-2012 03:13 PM
Hi Shawn,
I am having this problem (VIAssemblyException "Failed to call InitLVClient function.")
I am forced to use .NET 4.0 as that is what my company is using. I'm the only LabVIEW user here so have relatively little influence. We want to call some of my LabVIEW 2011 code using .NET 4.0
What are the options?
03-21-2012 07:26 PM
Hi caleyjag,
LabVIEW 2011 has limited support for .NET 4.0 assemblies. The reason for this is that LabVIEW has CLR 2.0 compatibility which only enables .NET 2.0, 3.0 and 3.5 compatibility as seen in the Requirements for Using .NET Assemblies in LabVIEW Help document.
An alternative that you can use is build a standard C dll and call that dll from the .NET application. A description of how to begin doing this is available in the KnowledgeBase article How Do I Use a LabVIEW DLL in Microsoft Visual Studio.NET?