Attaching one component to another crash: 'template mismatch during attachment'

I encountered this bug when trying to swap out the Skeletal Mesh Component type in C++ (removing a marketplace plugin) – from USkeletalMeshComponent to USkeletalMeshComponent.

I ended up having to just revert the changes with git and try again with a more step-by-step approach.

  1. Create a custom empty class in C++ that is a subclass of the plugin’s component (e.g. UMySkeletalMeshComponent).
  2. Swap the component type in the blueprint’s settings (from the plugin’s to my new one that is a subclass to the plugin’s component)
  3. Go back into the code and change the parent class for your custom component, build the project (editor will need to be closed)
  4. Open up & hopefully it’ll be happy

Of course that can cause other issues but they’re more standard fare than this one.

Also if you’re reading this and aren’t using version control, Unreal trashes blueprint binaries in an unrecoverable way pretty frequently. It’s worth it to set something up just to take the sting out of those issues.