LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Actor Framework .NET Reference Corruption

Solved!
Go to solution

The subject is the best I can describe it. I have an actor framework application where I am storing the refnum to a .NET assembly in the actor private data. Creating the reference and using Invoke Node for a method that only reads data doesn't seem to have an issue. However, periodically when I use Invoke Node for a method that writes data, the refnum becomes invalid. That is to say that it can run fine sometimes, and not others. It is like something corrupts the .NET refnum somewhere along the line. I started checking the refnum when I first read it, and it reports it is not a valid refnum, then the invoke fails.

 

I have my development VI which is just a linear string of Invoke Node that has been running for a week or two without issue, but I'm not storing the refnum anywhere in that case.

 

These are the errors I'm getting...any ideas on how to debug this? 

 

Error 1 occurred at Invoke Node (followed by the call chain)

 

Possible reason(s):

LabVIEW: An input parameter is invalid. For example if the input is a path, the path might contain a character not allowed by the OS such as ? or @.

0 Kudos
Message 1 of 10
(3,987 Views)

Storing the reference in class data shouldn't cause different behavior. Are you sure you aren't overwriting the reference with a bad value somewhere? 

 

Maybe try creating a test VI where you call all your actor methods in a row, and see if the problem still occurs?

0 Kudos
Message 2 of 10
(3,975 Views)

No matter where you store the .NET reference (or any LV reference), if the VI hierarchy that created the reference stops running, the reference is closed.

 

So if you run a class init VI from VI A, and pass the class to an actor, the actor can use the reference. But when VI A stops running, the reference is closed.

 

Not sure if that's what happening, but it seems relevant.

0 Kudos
Message 3 of 10
(3,974 Views)

Both good thoughts.

 

To paul.ross, after creating the reference, all the other VIs only ever read it. The only other write is my disconnect method. So I don't think this is an issue. I can press the Write button to send the Write message n times, and n+1 times it will report the reference is invalid.

 

To wiebe@CARYA, this seems a bit more plausible since I didn't see the issue before in my linear VI that I was testing the .NET assembly in. In that scenario, I would create the reference, use it multiple times, even in a fast loop, then close it. I never once had this issue. All that said, I'm not using any nested actors, only the main actor right now, and that's the actor that creates the reference.

0 Kudos
Message 4 of 10
(3,960 Views)

Hm.. Any chance you can post your code? Can you do like I suggested and just call your actor methods outside of actor core for testing? 

0 Kudos
Message 5 of 10
(3,952 Views)

The .NET code is an interface to hardware. Maybe I can create a modified version for this type of testing that doesn't actually write or read the hardware.

 

I created some new methods to check the reference before a method and after a method. Just reading the reference without any invokes reports an invalid reference.

 

What does that look like to call the actor methods outside of actor core? Never done that before...issues have always been more transparent than this.

0 Kudos
Message 6 of 10
(3,946 Views)

What I mean is just calling them in another VI - Create a dummy test VI that just calls your actor methods in a row - init then read/write (maybe in a loop) then close. That way you eliminate the chances of any other code being called that you aren't aware of. 

 

One other question - what else is in that actors class data? If it isn't the reference dying because the caller stopped as wiebe@CARYA suggested, it may be that somewhere in your code you are passing out the default value of the class - double check your for loops and case structures to be sure that isn't happening anywhere. Depending on what else is in your class data this may be obviously not the problem. 

0 Kudos
Message 7 of 10
(3,940 Views)

What is useful to you? I have reduced the actor data to nothing but some front panel references, and the .NET reference. Here is my one actor method that I run (besides creating the reference and initializing). Here I check NetReference before and after the method to see if it is invalid. When the error is thrown, the reference is invalid immediately after reading it from the actor private data. 

 

image.png

0 Kudos
Message 8 of 10
(3,928 Views)

Ah, then what I was thinking may be happening probably isnt. I was thinking you may have a method somewhere that you are passing the default value of the actor out of the method, losing your active reference - but if you have other references in class data, that probably isnt the case. 

 

Even without the hardware, seeing your code may be helpful..

0 Kudos
Message 9 of 10
(3,922 Views)
Solution
Accepted by CanadaGuy

Well, isn't this embarrassing...It appears a rogue key binding had shown up on my Disconnect button. I wasn't consistent with whether I would click the Write button, or press Enter to trigger the value change. Whenever I would accept a value with Enter it would change the value this time, but also trigger the disconnect which of course invalidated the refnum.

 

What really bothers me is that this has happened before, but I've never been able to replicate it. An Enter/Return keybinding shows up on some random element...it could be a button, a Tab Panel, or anything else. I think I've reported it in the past, but I have no way to replicate it or describe when it happens.

0 Kudos
Message 10 of 10
(3,906 Views)