12-31-2013 08:17 PM
Hi,
We have many C# project and I would like to integrate them in LabVIEW . Each C# projects contains thousands of lines, many classes.
I have found this article very helpful, however it is very basic.
http://erdosmiller.com/blogs/news/6605401-integrating-labview-and-c-1
Using this article I can use a class constructor to call all the methods but I always get object null reference problem in LV. The problem is all these classes are dependent to each other.
As an example :
somewhere in the code I should use the constructor of a class called NIAnalogOutput and then call the methods inside this class
as can be seen below inside the constructor it uses 2 objects from other classes: clsSystemInfo and SystemBusType
If I delete that line and then compile and use the dll file in LV I don't get any error
However if I keep this line in the constructor and compile the code I will get 1172 (null reference error ) in LV
I even tried to call the constructor of these classes and then call NIAnalogOutput but I still get the 1172 error. Could you please help me on this? How can I get rid of the error in this example?
in the attached picture you can see that I call the 2 class constructors (then all pass OK) before callingNIAnalogOutput
but I still get an error from NIAnalogOutput constructor
public NIAnalogOutput(string[] DeviceAndChannelName, double maxVal, double minVal, bool isMaster = false, eNIAOutCalOpt eCalOption = eNIAOutCalOpt.USE_STATIC)
{
this.master = isMaster;
if (eCalOption != eNIAOutCalOpt.NONE)
{
// Go change the niScales to either the static brdOffset values, or immediately measured values
UpdateAnalogOutputBoardOffset(eCalOption);
}
Dictionary<string,List<string>>devicesAndChannels = new Dictionary<string,List<string>>();
List<string> devices = new List<string>();
List<string> tmpChannels;
string[] tmpString;
int key_idx = 0;
NrOfChannels = DeviceAndChannelName.Length;
rNum = new Random(Environment.TickCount);
int chanIndex;
//#if PCI
if (clsSystemInfo.DAQmxInfo.sysBusType == SystemBusType.PCI)
{
SyncSignal = "RTSI5"; //not functional yet!!!
SampleClkSignal = "RTSI4";
GlobalSyncSignal = "RTSI3";
}
}
01-02-2014 03:52 AM
Hi Tintin,
I believe that this is a duplicate of your post here: http://forums.ni.com/t5/LabVIEW/C-code-in-LabVIEW/m-p/2680359#M797580
Can I ask in future that you try and keep all related content with regards to your question in the same thread as it makes it easier for people to track and follow your issue.
Best Regards,
James Kent
01-02-2014 10:06 AM
Hi James,
One of the members suggested me to make a thread in c# forum instead of LabVIEW forum and so I created a topic here
Any help on this issue is really apprecaited . How can I handle dependency between C# classes in LabVIEW to not get Null reference object error