"invalid texture reference"

I’m getting the attached message with the following code when trying to set a render target as a material parameter:

222585-errormsg.jpg

Line 52 is correct?