Showing results for 
Search instead for 
Did you mean: 

Calling Labview DLL from a C# app

I'm calling a Labview generated DLL containing multiple VIs from a C# application.
If I compile one VI at a time in a DLL, the function CALL is workink fine and the return values are properly calculated.
If I compile the whole bunch of VIs, there is no execution error, but the return values are all set to zero.
I cannot figure out what could be the problem.
0 Kudos
Message 1 of 13

Thank you for contacting National Instruments. I have not encountered the problem you are seeing. Attached is a small zip file containing a C# application that calls a 4 LabVIEW VIs compiled into a single DLL. The function prototypes (as defined in the LabVIEW-generated header file) are:

void __stdcall Divide(double Numeric2, double Numeric, double *answer);
void __cdecl Subtract(double Numeric2, double Numeric, double *answer);
void __cdecl Multiply(double Numeric2, double Numeric, double *answer);
void __cdecl Add(double Numeric2, double Numeric, double *answer);

As you can tell, even calling convention does not matter when calling the DLL from C#. The only LabVIEW output required in the C# project is the DLL which m
ust exist in the <C# project>\bin\Debug folder.

Please let me know if this addresses your issue!

David McClelland
National Instruments
Download All
0 Kudos
Message 2 of 13

hello, when I try to run the above c# code in (c# express 2008), I get a LoaderLock error.


DLL 'C:\Program Files\National Instruments\Shared\LabVIEW Run-Time\7.0\DNCompInfo.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.


I have no idea what that message means, and what to do about it.

 Any idea's?


0 Kudos
Message 3 of 13

Hi there


what .NET frameworks are installed on your system?


I'm able to run the app with .NET 2.0, XP SP3.


Best regards

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 4 of 13

I am running version 3.5, I just installed the vs C# express edition.

I also have XP SP3 

0 Kudos
Message 5 of 13

there is also installed v3.0, v2.0....


I've just realised that this (error is not an error but a warning) warning is only generated when I run the app in the debug mode of visual studios.

The warning occurs when the btnEquals_Click(...) method is called.

But if I click Debug "continue", the app functions as it should do. So I guess that visual studios is telling me that there is a problem, but the application works anyway.

Also the build .exe file runs normally. 


I guess this is the wrong place to ask why I get this warning.

Thanks paul. 

0 Kudos
Message 6 of 13


I have bild VI that is containing multi lavel subVIs. The ganerate dll with lib and h files was suplied to customer.

Our customer working on " C++" and didn't have any expirience with LabView generated dll.

How he can get the list of function that is needed inorder to integrate our soft in customer aplication. 

0 Kudos
Message 7 of 13

hi there


the customer just needs the dll, the .h (generated during the build of the dll), the correct version of the LV runime engine installed on the target system (can be downloaded for free at and maybe the user manual of your dll in order to call the functions in the right order with the correct parameters. 

Best regards

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 8 of 13


what  do you mean user manual of dll?in .h file I can find only main VI name .can you explain me more details because my programming level not so good  


0 Kudos
Message 9 of 13


The .h file generated during build should look somehing like this:



#include "extcode.h"
#pragma pack(push)
#pragma pack(1)

#ifdef __cplusplus
extern "C" {

void __cdecl Fun1(double Numeric, char String[], int32_t len);
void __cdecl Fun2(double Numeric, char String[], int32_t len);

long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);

#ifdef __cplusplus
} // extern "C"

#pragma pack(pop)



In this example wo functions Fun1 and Fun2 are exported. If you can't see such function declarations then there's something wrong with your dll build specification. Check the "Prototype definition" of the functions you want to export on the "Source file" tab of the build specification. Press "Help" on the build specification dialog box for details.


"User Manual" simply means a description of how to use the functions of the dll. A .h just says how to call he functions, but NOT how to use them correctly.

Best regards

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 10 of 13