04-18-2009 08:32 AM
Hi all! I'm getting an error when calling LV8.5 created in VB.net. I use PInvoke to call the dll, I'm getting the error saying"Object Reference not set to an instance of the object" The call is: <DllImport("D:\\Inetpub\\wwwroot_terco\\LabServer\\ExperimentSetups\\ExperimentWrappers\\OpAmpInverter\\LabView\\SharedLib.dll", EntryPoint:="OpAmpInverter", CallingConvention:=CallingConvention.StdCall)>Public Shared Function runExperiment(ByVal FrequencyHz As Double, ByVal PeakAmplitudeV As Double, ByVal DCOffsetV As Double, ByVal WaveformType As Short, ByVal SamplingRate As Double, ByVal SamplingTime As Double, ByRef OutputWaveform As Double(), ByVal len As Integer, ByRef errorOut As TD1) As Integer. But when I disable this function and put the real values without calling from labview, like:Public Shared Function runExperiment(ByVal frequency As Double, ByVal amplitude As Double, ByVal offset As Double, ByVal waveformType As Short, ByVal samplingRate As Double, ByVal samplingTime As Double, ByRef waveform As Double(), ByVal len As Integer, ByRef errorOut As TD1) As Integer waveform = New Double() {100, 0.1, 0, 200, 0.2, 0, 300, 0.4, 0, 10}. I get the result. The code below is the sharedLib.h
#include "extcode.h"
#pragma pack(push)
#pragma pack(1)
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
LVBoolean status;
int32_t code;
LStrHandle source;
} TD1;
void __stdcall OpAmpInverter(double FrequencyHz, double PeakAmplitudeV,
double DCOffsetV, uint16_t WaveformType, double SamplingRate,
double samplingTime, double OutputWaveform[], int32_t len, TD1 *errorOut);
long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);
#ifdef __cplusplus
} // extern "C"
#endif
#pragma pack(pop)
04-20-2009 10:22 AM
Hey teyana,
Have you checked out our Developer Zone about calling LabVIEW from other programming languages?
It has some great troubleshooting and examples to look over. Nothing really jumps out at me in your code, but I am not nearly as proficient as some peope in VB. I will look into it though.