From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Return value by reference from .Net method

Hello everyone,

Can anyone help how to return value from .Net method by reference (address)?

Below the code which cause LV crash when calling given GetPara(...) method.

When method is skipped the code works fine.

The original method definition from external library header file is:

int32_t GetPara(uint32_t para, uint64_t &data, uint8_t dm_id=0);

The parameter "data" is U64 return value which I need to retrieve.

Example ReturnByRef from .Net.png

I tried to do something like below but with no success.

There is no methods or properties available to get U64 data value.

Anyway this both ways cause LV memory crashes immediately.

Example ReturnByRef from .Net - Potentail Solution.png

 

Many thanks in advance.

Artur

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

1) forget about DVR's. DVR's do not have anything to do with pointer. Nothing. No change at all that you'll get anything good from them in this situation.

 

2) Any change you can change this? The .net interface I mean? It seems like a terrible idea. AFAIK, values can be set to in\out, so a normal U64 in\out would do. Or a separate U64 in, another U64 out?

 

3) We can't run this. So we also can't test anything... If you made this assembly, can you post one with just the problem method. Preferably with as little clutter as possible?

 

4) I'd try something like this:

 

 

If you can't avoid it, I'd try to do something like this.

 

Example ReturnbByRef From .NET.png

Not to sure about the cast from void* to Uint64*...

 

You need to focus your search on "Marshal" and "explicit conversion". Problem is in e.g. C#, this object magic is either done automatically, or not done since it's a bad idea.

 

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