LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Call .net dll event in LabVIEW

Solved!
Go to solution

Hi All,

 

Any one help me to understand C# dll event step and convert into LabVIEW. attached files (LV Source code, Supporting DLL) for your reference 

 

C# code - Event step

-------------------

private static void Instance_InterfaceCollectionUpdate(IEnumerable<IHardwareInterface> added, IEnumerable<IHardwareInterface> removed)
{

   .................
}

 

Advanced thank you 

 

Regards,

Prashant Vernekar 

0 Kudos
Message 1 of 5
(1,412 Views)

You don't call events - you provide a handler (eg. your callback VI or the C# method snippet you posted) and the thread that executes the event will call it when the event is fired.

 

You have created a callback for the event, but forgotten two things:

 

  1. Your callback has no logic. It has parameters for the IEnumerables but you're doing nothing with them. The example Program.cs you provided contains some logic to display the added and removed items - you could replicate this in a number of ways (popups, passing data back to your Demo.vi etc.). Based on your Demo.vi, you already know how to enumerate the IEnumerable items.
  2. Your Demo.vi ends abruptly, so there's no guarantee the event is even fired. The example Program.cs you provided contains a loop waiting for 250ms before shutting down and exiting; perhaps try replicating that.
0 Kudos
Message 2 of 5
(1,368 Views)

Hi tyk007,

 

Greetings for the day.

 

Thank you for your replay.

 

but I'm getting some error like "System.ArgumentNullException: Key cannot be null.". attached error image for your reference.

 

Please help me, if i missing any configuration device manager before read device name.

 

Thanks,

Prashant Vernekar

0 Kudos
Message 3 of 5
(1,322 Views)
Solution
Accepted by topic author Prashant1991

.Net IEnumerator's are always initialized to point to the record previous to the first one, aka invalid. Same is true if you call Reset() on an IEnumerator.

You need use a loop and call MoveNext() first before you can retrieve a Current() value.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 5
(1,312 Views)

Thank you rolfk 

 

now its working fine 

 

Thanks,

Prashant

0 Kudos
Message 5 of 5
(1,297 Views)