Jump to content

Calling dlls made in LabVIEW 2011 in Visual C# .NET 4.0?


Recommended Posts

Hi all,

I've been trying to figure out how to get a function made with LabVIEW 2011 up and running in MS Visual C# 2010 (.NET 4.0)

I've been using this guide:

http://zone.ni.com/reference/en-XX/help/371361H-01/lvhowto/building_a_net_assembly/

When i try to execute the code I made in visual studio I get the following error:

Failed to call InitLVClient function

I've seen this thread:

http://forums.ni.com/t5/LabVIEW/VIAssemblyException-quot-Failed-to-call-InitLVClient-function/td-p/1472988

My question to you is, is it possible to create LabVIEW 2011 code for use in Visual C# 2010?

If so does anybody have a link to a guide on how to export LabVIEW 2011 VIs into a format that can be called from Visual C# 2010? Even better yet, does anybody have any example code I could work off?

Link to post
Share on other sites
  • 2 weeks later...

http://zone.ni.com/r...a_net_assembly/

Calling the .NET Interop Assembly from Another Program

After you build a .NET interop assembly, you can call the assembly from other programs that support .NET. However, ensure that the computer on which the other program runs meets the following requirements and recommendations:

  • The LabVIEW Run-Time Engine must be installed on any computer on which users run the .NET interop assembly. You can distribute the LabVIEW Run-Time Engine with the .NET interop assembly. (Windows) You also can include the LabVIEW Run-Time Engine in an installer.
  • National Instruments recommends that the target computer for the .NET interop assembly have the same or later version of the .NET Framework installed as the version that LabVIEW used to build the application.
  • To call the .NET interop assembly outside of the LabVIEW development environment, you must referenceNationalInstruments.LabVIEW.Interop.dll in the Microsoft Visual Studio project. The LabVIEW Run-Time Engine automatically installs this DLL to the National Instruments\Shared\LabVIEW Run-Time directory.

------------------------------------------------------------------------------------------------------------------------------------------------------

I built (interop assembly) a virtual keyboard in LV2011 64bit and a coworker is able to successfully call it from both C# and C++. I had the LabVIEW.exe.config set to <supportedRuntime version="v4.0.30319"/>. My coworker had to specifically target 64bit processor (instead of 'Any Processor') in C#. This seemed to have something to do with witch LV Runtime engine was called (32 vs 64)

Good luck

Denis

Link to post
Share on other sites

I was having exactly the same problem, and was told that LabVIEW 2011 does not compile for the 4.0 framework. Try targeting your C# project for .NET 3.5. That's what I did, and it works just fine.

OOPS, my bad. The LV2011 32-bit does not compile to ver 4.0.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By torekp
      DLL functions or shared variables?  Or something else?
      I have a Labview 2014-64 executable (or I can build a DLL) that runs one piece of equipment, the X-ray.  The other engineer has a large CVI Labwindows 2015 + MS Visual Studio 2012 (C++) executable that runs everything else.  I want the Labview code to be a slave of the CVI code, accepting commands to turn X-ray On or Off, reporting failures, and the like.  Translating the X-ray code into C++ would be possible in principle, but not fun.
      Shared variables look easy, but I'm kinda scared of them.  I would define all the shared variables in my LV code, since I'm more familiar with LV, then use them in both.  There's a thread in here called "Shared Variable Woes" so maybe I should be scared.  In the alternative, I tried building a proof-of-concept DLL in Labview, and calling its functions in CVI/C++, and it works, but it's kinda clunky.  (I'm attaching it below in case you want to play, or advise.)
      Your advice would be appreciated.
      XrayDLL.zip
    • By patufet_99
      To use a controller from LabVIEW I have to use some functions of a DLL.
      For one of the functions, according to the header file .h there is a structure data with parameters of different types that I have to pass to the dll. Some of the parameres are BYTE (1 Byte)  and WORD (2 Bytes).
      When compiling this kind of structure with Visual C++ and looking at it's size with "sizeof()" it seems to me that 4 Bytes variables have to start in a position multiple of 4. For example if there is a BYTE and then a DWORD, the 3 Bytes after the BYTE are ignored and the DWORD starts at Bytes 5 to 8.
      When defining a LabVIEW cluster to match the DLL structure, will LabVIEW do the same? If in my cluster there is a U8 variable and then a U32, will anyway the U8 take 4 bytes?
       
      Thank you.
    • By torekp
      So I created a DLL from a Labview VI that has a 2D array input (and some scalar inputs) and some 2D array outputs.  Labview creates a .h file with these lines

      And then it defines the 2D array arguments to my function as being of this type: "void __cdecl Linear_discrim_4dll(DoubleArray *dataObsFeat, int32_t grpAsz," etc etc.  Trouble is, I have no idea how to fill out this structure so that the DLL can use it.  Say for simplicity I had a 2 by 3 input called dataObsFeat with elements {1,2,3; 11,12,13}; how would I create the object with these values in C or C++ and pass it to the function?  I am a total C++ noob, in case it isn't obvious.
    • By Fred chen
      Hi
       
      When I call the DLL, there is a structure:
      struct Signal { uint32 nStartBit; uint32 nLen; double nFactor; double nOffset; double nMin; double nMax; double nValue; uint64 nRawValue; bool is_signed; char unit[11]; char strName[66]; char strComment[201]; };  
       
      There is another  Message structure to the above Signal:
       
      struct Message { uint32 nSignalCount; uint32 nID; uint8 nExtend; uint32 nSize; Signal vSignals[513]; char strName[66]; char strComment[201]; }  
        The point is  Signal vSignals[513];
       
      I've tried to solve it like this,but the program will crash.
       
      How to create struct Message ,any good suggestions?  Thanks a lot.
       

      message.vi
    • By x y z
      Hello!

      I'd like to resize LStrHandle string in a C++ based DLL ... which is perfectly working on desktop Windows (ex.:Win7 32/64 bit) platform by include "extcode.h"  and linking "labviewv.lib", with calling "NumericArrayResize" function.
      BUT I'd like to do the same on Windows Embedded Compact 7.0 with ARM(Cortex-A8).
      When I build the DLL project on "Smart device / WindowsCE" platform it compiled successfully but the linker stopped because "NumericArrayResize" is unresolved symbol ... I think the reason is that the "labviewv.lib" generated for x86 architecture not for ARM.

      So my question is: Is there any libviewv.lib for ARM platform?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.