LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing .Net Reference as a Parameter to a LabVIEW Interop Assembly Build

I've built an Interop Assembly containing a Labview VI that accepts a .Net object as an input parameter.  When I call this method from a .Net application, it's looking for a 'LVReferenceNumber' structure.  This structure seems to need an IntPtr structure to my .Net input parameter.  It's difficult to find documentation on this subject, and that's as far as I've gotten.  Can anyone help me pass a .Net object into a Labview Interop Assembly?

 

--I'm using .Net 3.5 (Visual Studio 2008) and LabVIEW 2009

 

Thanks for your help!

0 Kudos
Message 1 of 9
(5,972 Views)
Unfortunately, I believe your issue might be related to a bug.  This was reported to R&D (CAR #167819) for further investigation.  Its description is a little bit different but I think it's related.  I will follow up with R&D and try to determine whether or not this is the cause.  If not, we can continue looking into the issue.
Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 2 of 9
(5,935 Views)

Is there any more information available on this topic?  Is there somewhere that I can review the CAR to see if that issue and mine are the same?

 

It seems like there most be some way to do this because I can do it in TestStand--create the .Net object using a .Net module and then pass it into the Labview VI module.

0 Kudos
Message 3 of 9
(5,893 Views)

There is not a public way to view the CAR information but a summary of the description follows:

 

"I created a VI that takes a .NET reference.  I then created a .NET assembly using this VI and I noticed that the type of the .NET reference was set to LVReferenceNumber.  This prevents me from passing a real .NET object since I don't see how I can create a LVReferenceNumber."

 

To clarify your last comment, are you saying you can call into the same .NET assembly (created from the VI) through TestStand but not .NET? 

Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 4 of 9
(5,872 Views)

I take that back--I tried it today.  I cannot pass the .NET reference to the Labview assembly or the original Labview VI.  Trying to pass an object reference to the Labview assembly in TestStand results in a type conflict.  Trying to pass an object reference into the original VI through TestStand does not give an error, but the information is not passed in or out.

0 Kudos
Message 5 of 9
(5,854 Views)
Does the description of the CAR sound like the same issue you are running into?
Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 6 of 9
(5,821 Views)
Yes, the CAR is the same issue.  I think the problem is that the input parameter (LVReferenceNumber) is used in unmanaged memory while the .Net object is, of course, managed memory.  I just don't how (or if it's possible) to move my .Net object between the two.
0 Kudos
Message 7 of 9
(5,787 Views)
Due to the CAR, there does not appear to be a way to pass the .NET object at this point.  I certainly apologize for the inconvenience of running into it but hopefully we will see it fixed soon.
Alex Person
NI-RIO Product Support Engineer
National Instruments
0 Kudos
Message 8 of 9
(5,764 Views)

Hello Alex,

 

I have been experiencing a similar problem as described above, where my .NET object constructor requires two .NET objects to be passed as parameters (see attached image).  Each of the initial objects pictured here (Configuration and Calibration) instantiate without a hitch, but when I attempt to initialize the final object (IQA shown here) the constructor fails with an error 1172, referencing the following message:

 

 

(System.NullReferenceException: Object reference not set to an instance of an object.
)

 

"System.NullReferenceException: Object reference not set to an instance of an object."

 

I expect that the reason for the above error is a similar explanation as your previous response, however I would like to see if any progress has been made on this problem, or whether this issue might be addressed in a future version of LabVIEW (NI-Week 2010???).

 

Can you tell me if this is the same (or a similar) problem?

 

Kind Regards,

 

Ken

0 Kudos
Message 9 of 9
(5,570 Views)