Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

C# code in LabVIEW

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";
            }

}

 

 

0 Kudos
Message 1 of 3
(8,728 Views)

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

James Kent | Applications Engineer | National Instruments UK & Ireland
w: uk.ni.com | ireland.ni.com
0 Kudos
Message 2 of 3
(8,690 Views)

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

0 Kudos
Message 3 of 3
(8,679 Views)