LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing a .NET assembly by String reference

Could anyone offer me some assistance in implementing this C# code in LabVIEW?  I have a Skywave.DAPC.dll file in the same folder as the VI, which contains the referenced object (CDapDelivery).  I can't seem to figure out how to create the List of CDapDelivery objects.

 

List<CDapDelivery> DapDeliveries = DapSession.Send(DapInitiateDelivery);

0 Kudos
Message 1 of 12
(3,881 Views)

You shouldn't need to create that. The method's return value will give you that as a reference.

0 Kudos
Message 2 of 12
(3,877 Views)

I can't seem to make a constructor for the System.Collections.Generic.List.  I found another way to do it here: http://forums.ni.com/t5/LabVIEW/How-do-I-create-a-NET-List/td-p/888138, but when I try to use a reference to my Skywave.DAPC.CDapDelivery, it fails saying the reference is Null.

0 Kudos
Message 3 of 12
(3,875 Views)

For example, attached is my simple VI to create a List of System.String objects.  It can be seen if I call a ToString() Method that the reference exists.

0 Kudos
Message 4 of 12
(3,872 Views)

When I try to create a List of the object in my third party .NET assembly (Skywave.DAPC.dll), it fails and I get a Null reference, even though the .dll is located in the same folder as the VI.  The error states that the parameter Key is Null.

0 Kudos
Message 5 of 12
(3,869 Views)

Yes, I already know how to do that. What does that have to do with the question? As I noted, the method will return to you a reference that is that list, so why are you bothering to create the list in the first place?

0 Kudos
Message 6 of 12
(3,868 Views)

What Method are you referring to?

0 Kudos
Message 7 of 12
(3,864 Views)

DapSession.Send(DapInitiateDelivery) ... the one you said.

 

Did you not create a DapSession? If you connect that to an Invoke Node you'll see the list of methods. Select the "Send" method. You need to feed it a DapInitiateDelivery object, which I assume you've created somewhere else. The output of that function will be your list. You do not need to create the list yourself. Just like in the example you posted, the output of the GetType method is of a System.Type class. That wire that is of that type.

0 Kudos
Message 8 of 12
(3,861 Views)

Well that's a bit confusing...thank you for the help! The next part of my mission, which is to iterate through the List of CDapDelivery objects and take an action based on whether that object is of type CDapMessage or CDapNotification, should be interesting.  If you have any recommendations on the best way to do that, I'd appreciate it!

 

0 Kudos
Message 9 of 12
(3,854 Views)

The List's Count property can be used to drive a for-loop and inside the loop you can use the get_Item method to get the individual items.

 

You said "take an action based on whether that object is of type CDapMessage or CDapNotification". The list is a list of type CDapDelivery. Is there some relationship between the CDapDelivery class and the CDapMessage and CDapNotification classes?

0 Kudos
Message 10 of 12
(3,852 Views)