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

I explain the problem and suggest some solutions here. Hope this helps others.