As you seen in this picture below, for some reason my DirectCast wont except ANYTHING for the second argument. It says it requires a type, but, it won\'t take any object at
DirectCast
requires an object prototype (i.e. just giving it the intended class name) rather than a System.Type
descriptor object. To cast an object using a System.Type
, you will want to utilize CTypeDynamic():
Return CTypeDynamic(createElementByIdAndLayer.MemberwiseClone(), objType)
The error is essentially telling you a class with the type name "objType" does not exist.
Its expecting a "Type", not a "Type Object".
What is the return value of the function?