LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

.NET DLL call returns wrong value

Hi,

 

I try to develop an application which based on a .NET dll (builded in LV). In the meanwhile I found a weird behaviour which I can reproduce in a small project (see attached zip). The problem is if I call a dll method, which contains a "wait on asynch call" with a specified timeout, then in case of wait timeout the method will be returned with default value instead of the "real" correct value (of course it works if i dont build and use the dll).

Project structures:

  • DLL_error project
    • foo: inf wait in case of TRUE input, else returns immediately
    • start: calls foo asynch and waits (5 sec) on asynch call, returns and shows (w/ dialog window) a simple string
    • DLL build spec, export start method to DLL (DLL_NULL_POINTER.dll)
  • DLL_User project:
    • main: calls DLL.start
      • Use case 1: input TRUE
        • returns correct values
      • Use case 2: input FALSE
        • returns default values, and not the correct values from start.vi

It seems "use case 2" does not behave properly (compare modal window and stingOut values).

Somebody could confirm it that is a bug, or it works as specified and I use the dll wrong?

 

Thanks for any help,

 

Balint

0 Kudos
Message 1 of 3
(2,291 Views)

Hi,

 

it the same message above, I improved the description a little bit.

 

I try to develop an application which is based on a .NET dll (built in LV). I found a weird behaviour which I can reproduce in a small project (see attached zip). The problem is that the dll returns different values than the VI that the dll is wrapping. Specifically, the returned class instance (it’s a OOP application) is null and the returned application-specific value is the default value of the type. Note that the original LV code never returns these values.

It seems that the behavior has to do with the "wait on asynch call" VI. If there is no timeout, everything works fine. In case of timeout the dll (when called from LV, I didn’t test it otherwise) returns the wrong values (see above). Note that the application works fine if I don’t use dll (as pure LV application).

Project structures:

  • · DLL_error project
    •  DLL_Class.foo() vi: waits forever in case of TRUE input, else returns immediately.
    •  DLL_Class.start() vi: calls foo() asynchronously and waits (timeout = 5 sec), returns and shows (via dialog window) a simple string.
    •  DLL build spec, exports start() method to dll (DLL_NULL_POINTER.dll)
  • DLL_User project – uses above dll:
    • main(): calls DLL_Class.start() via DLL_NULL_POINTER.dll
      • Use case 1: input TRUE, returns correct values
      • Use case 2: input FALSE, returns default values, and not the correct values from start.vi

It seems "use case 2" does not behave properly (compare modal window and stringOut values).

Can anybody confirm that it is a bug? Or, am I using the dll wrong in a wrong way?

Thanks,

Balint

0 Kudos
Message 2 of 3
(2,235 Views)

Sorry for spamming the thread, but it turned out, that the problem is more generic. That means, it is independent from error (in my example the "wait on asynch" call thrown an error). An additional information, if I turn on "lv 2011 compatibility mode", then this weird behavior of .net DLL disappears. The question is still, is it anywhere specified (I found only that)?

 

Balint

0 Kudos
Message 3 of 3
(2,196 Views)