Introspection is a very handy and useful part of the Xojo language.
You can use Introspection to examine many of the objects that are in memory at runtime. You can access the properties in those objects, call methods on those objects and even create new instances- with some caveats of course.
There are limits to what you can do with Introspection. You can’t use it to create things that do not exist at runtime because the Xojo compiler will have removed them from the app. What might something like that be?
Suppose you have a class, MyCoolClass, and nowhere in your app do you use it. You have no property of that type, you never had any “IsA MyCoolClass” checks and never Dim a variable as MyCoolClass. Then the likelihood your class has been stripped out of the final built executable during compilation is high. Basically, if you never use the class, it will likely get stripped out.
And there is no way for you to create one at runtime “by name” because there is no “make me this class by name” operator or function.
Since it’s only possible to create classes that exist at runtime, you need to make sure they do not get stripped out. The easiest way to do this is to make sure you use the class somewhere in your code. Some like this is sufficient:
Dim info As Introspection.TypeInfo = GetTypeInfo(MyCoolClass)
Now your class is referenced and it will not be stripped out. Now you can create instances from the TypeInfo by accessing the class’ constructors.