Dynamically attach scene component to scene component in code

I am trying to dynamically spawn and attach a scene component to another scene component, but so far I encountered two different issues. This component class was created in two different projects, one is as part of a plugin, the other is part of the project.

In the plugin, this component class will result in an ensure condition fail when I inherit from a blueprint actor that has this component. The ensure condition is “Template Mismatch during attachment. Attaching instanced component to template component”

In the project, this component class will cause a fatal error, “Unhandled Exception: EXCEPTION_STACK_OVERFLOW” and the project will not be able to run.

My question here is, am I not allowed to create and attach a scene component to another scene component in code?