Animating other object

I have an animation that I want to apply to whatever my character is holding in my FPS. The objects that can be picked up have no animations applied to them prior to runtime.

I am currently using this code with no luck:

holdingAnimation = holding.transform.gameObject.AddComponent("Animation");
holding.transform.gameObject.animation.AddClip(AnimationClip.walkForwardClip, "clip1");
holding.transform.gameObject.Play("clip1");

in debug is says: “NullReferenceException
UnityEngine.Animation.AddClip (UnityEngine.AnimationClip,string,int,int) <IL 0x00009, 0x0005e>”

What am I doing wrong?

Have you found an answer to this problem?