Project Geometry Service Failed event - UserState object type does not match

866
5
11-22-2011 08:24 PM
AndrewBiggins
New Contributor III
Hi,

I am using a geometry service's ProjectAsync method to project some graphics in an application, and I am passing the graphic layer name as a string using the userToken parameter:

GeometryService ProjectShapefileService = new GeometryService(_geometryServiceUrl);
ProjectShapefileService.ProjectCompleted += ProjectShapefileService_ProjectCompleted;
ProjectShapefileService.Failed += ProjectShapefileService_Failed;
ProjectShapefileService.ProjectAsync(thisShapefileGraphics, _map.SpatialReference, shapefileName);


This works fine, except that when the project operation fails the UserState object that is returned via the Failed event (within the args object) does not match the type of the userToken parameter (in this case it is not a string). Instead it is a generic object array (see attached screenshot for debugging example).

private void ProjectShapefileService_Failed(object sender, TaskFailedEventArgs args)
{
 // This is what I need to do to get to the graphics layer name (passed via the userToken parameter)
 object[] thisUserState = (args.UserState as object[])[0] as object[];
 string thisShapefileName = thisUserState[2] as string;
 // If this worked like other geometry service methods, I should be able to do this instead. Why not?
 //string thisShapefileName = args.UserState as string;


Is there an easier way to get to the userToken parameter that was passed to the geometry service?

Cheers,
Andrew
0 Kudos
5 Replies
DominiqueBroux
Esri Frequent Contributor
Seems to be a bug. We'll try to get it fix in a future version.

Note that your workarond looks good for now but will fail when the bug is fixed.

Thanks for reporting that.
0 Kudos
AndrewBiggins
New Contributor III
Hi Dominique,

Thanks for your reply.

Is this a bug in the Silverlight API or in ArcGIS Server? I'm asking because I'm wondering when this bug might be fixed (and I'm hoping it is in the Silverlight API because then it might be fixed sooner!).

Cheers
Andrew
0 Kudos
DominiqueBroux
Esri Frequent Contributor
It's a bug in the Silverlight API.

You are lucky:)
0 Kudos
SurajKoneri
New Contributor II
Hi guys,

Is Silverlight API bug fixed? or there are any work around for this to fix, reply here. Thanks.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Hi guys,

Is Silverlight API bug fixed? or there are any work around for this to fix, reply here. Thanks.

The bug will be fixed in the next release (which should be released soon).
Andrew shared a workaround in his first post.
0 Kudos