From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing .NET object to Interop Assembly vs. .NET Singleton

I try to achieve something like a .NET event handler, e.g. a .NET class that receives simple data during the run of a call to a LabView Interop assembly.

I'm not a LabView expert so i tried the following:

 

1. Create a singleton .NET class TestAttendant with some methods

 

2. Create a VI with a .NET Refnum as input and select the class TestAttendant, added the VI to Interop Build

    > Build Error: Unable to identify/generate type information of a .NET refnum

 

3. Use a general .NET Refnum as input solved the problem. Resulting CLR signature is

     public static void SetAttendant(NationalInstruments.LabVIEW.Refnums.LVBaseRefnum attendant)

 

4. Don't know which of the 279 derived types from LVBaseRefnum I should use to pass my TestAttendant singleton instance. I expect to do something with MarshalByRefObject?

 

5. Tried the other way around and called the singleton constructor twice, from .NET unit test and from LabView. Of course, both calls are done in different app domains, "IsolatedAppDomainHost: MyCompany.UnitTests" and "MyCompany.Interop.dll for Run"

 

 

Maybe my approach is not the best, I don't have to stick to the TestAttendant class. I only need some simple data during the LV run in the assembly from which i called the Interop.

 

Thanks in advance, Jonas

0 Kudos
Message 1 of 2
(2,339 Views)

Hi,

 

Let me get the Problem right:

 

You call an LabVIEW Interop-Assembly. That Assembly runs now, but has not finished to run.

Meanwhile, from somewhere in your calling Program you need data from the VI running as interop assembly in the runtime engine.

 

With LV Interop Assemblies it is the same thing as with LV Sub-VIs or DLLs... the output data only when they are finished. What do we do to get data into and from VIs when they are running? The easiest approach whil a build in function of LV is the use of shared variables.

 

Prinziple: you let the VI you pack into you Interop Assembly write the data you need into a shared variable - in addition to your functionality.

Another VI or LV Interop Assembly you can call whenevver you need to and let it read out the shared variable.

 

Regards

René

 

0 Kudos
Message 2 of 2
(2,230 Views)