RobotStudio event

How can I write to Rapid Data by using PC SDK ?

Koyu Karlstad Univercity
Hello all

I'm trying to write to Rapid Data (RobTarget) by using PC SDK.
I'm using 'Value' property and 'FillFromString()' method as in the code below.
However, if I do this, I will get this error:
C0048409 : An argument specified by the client is not valid for this type of operation.

RapidData rd = controller.Rapid.GetRapidData("T_ROB_R", "Module1", "Home");
IRapidData data = (RobTarget)rd.Value;

using (Mastership m = Mastership.Request(controller.Rapid))
        rd.Value = data;   

I'm just a beginner of PC SDK that I might make mistakes in this code.
Would you tell me where I'm wrong?

Best regards,