Class cast problem: error appears only once
I have got a strange behaviour when dynamically assigning an object to a terminal. The problem appears only at the first run. To get it again, the project or the whole LabVIEW must be reloaded. I assembled a simplified code illustrating the problem.
The project contains:
1) A LVOOP class ClassN. In this example, the class does nothing. It is used only to initialise the object wire.
2) Run-able main.vi that calls Wrapper.vi.
3) Wrapper.vi that calls internal.vi dynamically.
Important: object terminals of this VI have type of LabVIEW Object; thus, when main.vi calls it, up-casting takes place.
Wrapper.vi dynamically searches own controls. When the object-receiving control is found, it transfers the value to corresponding control of dynamically called internal.vi; then runs internal.vi.
4) The internal.vi does not do any enjoyable staff but shows a simple message.
Important: object terminals of this VI have type of ClassN; thus, when Wrapper.vi calls it, down-casting takes place.
When running main.vi first time, an error is launched: Error 91 occurred at Invoke Node in MethodWrapper.vi->main.vi Possible reason(s): LabVIEW: The data type of the variant is not compatible with the data type wired to the type input. Method Name: Control Value:Set
If running main.vi again (and again), the program works without errors. The error re-appears only if the project/LabVIEW is closed then opened again. The same behaviour takes place if I open the whole project or only main.vi.
I tried to simplify code of Wrapper.vi even more (tried to cast the object wire to variant and assign the obtained value; tried to use reference to the input terminal instead of searching for it, etc.) but could not get the same phenomenon.
What could be the reason?
The project is attached.
_____________________________________
www.azinterface.net - Interface-based multiple inheritance for LabVIEW OOP