# RapidData / RobTarget exception when reading

**URL:** <https://tech-community.robotics.abb.com/t/rapiddata-robtarget-exception-when-reading/3356>\
**Category:** Developer Tools\
**Created:** [February 10, 2010, 5:02pm UTC](https://tech-community.robotics.abb.com/t/rapiddata-robtarget-exception-when-reading/3356 "2010-02-10T17:02:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laro88](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/laro88/32/2653_2.png) [@Laro88](https://tech-community.robotics.abb.com/u/Laro88)\
**Post date:** [February 10, 2010, 5:02pm UTC](https://tech-community.robotics.abb.com/t/rapiddata-robtarget-exception-when-reading/3356/1 "2010-02-10T17:02:54Z")

</div>

I keep getting an exception that causes a crash in my app. Here is the exception:

ABB.Robotics.GenericControllerException: Invalid client id.  
ved Adapters.Data.Get()  
ved ABB.Robotics.Controllers.RapidDomain.RapidData.get\_Value()

Here is the code ( compacted a bit )

RapidData rd;  
RobTarget rt;

rd = theController.Rapid.GetRapidData(“TaskSystem”,“SysMain”,“robtargetCurrentPos”);  
rd.ValueChanged+=new EventHandler(rd\_ValueChanged);

rt = (RobTarget)rd.Value;  
log.Debug(“initialization rtCurrent was:”+rt.ToString()); //CRASH HERE

Basically I wish to **read** a robtarget from a task that updates the robtarget variable… So this should not require mastership…

---

<div class="post-metadata">

**Author:** ![Laro88](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/laro88/32/2653_2.png) [@Laro88](https://tech-community.robotics.abb.com/u/Laro88)\
**Post date:** [February 11, 2010, 9:23am UTC](https://tech-community.robotics.abb.com/t/rapiddata-robtarget-exception-when-reading/3356/2 "2010-02-11T09:23:59Z")

</div>

It appears that the read code somehow violates the Mastership requirement, don’t know why though.  
Here is some code that actually works without requiring mastership. Basically it only finds the RapidData and hooks up to its changed event.

Hookup snippet:  
rd = theController.Rapid.GetRapidData(“TaskX”,“ModuleY”,“robtargetZ”);  
rd.ValueChanged+=new EventHandler(rd\_ValueChanged);  
//Note that RapidData rd is declared in class scope to avoid destruction by mem cleanup.

Event reception snippet:  
void rd\_ValueChanged(object sender, DataValueChangedEventArgs e)  
{  
RobTarget rtChanged = (RobTarget)rd.Value;

Position p = new Position(rtChanged.Trans.X,  
rtChanged.Trans.Y, …
