Dynamically Load LabVIEW Objects Into a LabVIEW Application at Runtime

Updated Sep 15, 2023



  • LabVIEW

This article describes a method that enables you to load objects of dynamically dispatched child classes into a LabVIEW application from file. The design pattern that will be utilized in this article is known as the factory pattern, which is used in many different object oriented programming languages to modify the functionality of a built application after it has been deployed. For more information on the factory pattern, see the "Related Links" section of this article.

  1. Create and configure the necessary LabVIEW classes.
    1. Create a LabVIEW class that will eventually contain all of the methods that are intended to be overwritten via dynamic dispatch. The class that is dynamically loaded at runtime will inherit from this parent class.
    2. Create the prototype method(s) in the parent class that are intended to be overwritten by method(s) contained in the dynamically dispatched child class. These methods must be configured for dynamic dispatch.
    3. Create the child class that will inherit  from the top-level parent class created in Step 1.
    4. Create methods in the child class to override the methods configured for dynamic dispatch in the parent class.
    5. Repeat steps 1.3 and 1.4 for each child class that are required for your application.
  2. Write the code to load the child class in dynamically at runtime.
    1. Use "Get LV Class Default Value" to load the child class and instantiate an object of the child class represented as a default LabVIEW object type. 
    2. Cast the loaded object to be represented as an object of the parent class using "To More Specific Class".
    3. When operated on, methods of the parent class will be overwritten by the dynamically dispatched methods defined by the child class. The input "class path" on "Get LV Class Default Value" should point to the path to where the child class will be located on the computer that your application will be deployed on.
  3. Develop your code and deploy your application.
    1. Develop and distribute your application .
    2. Ensure that you have added the files for the classes that will be dynamically loaded to the correct directories on the computer(s) that will be running this application.