Select to view content in your preferred language

Problem with the Silverlight Find task

1727
11
11-03-2010 01:42 AM
JacobSaugmann
Deactivated User
I've followed the instuctions from this : http://help.arcgis.com/en/webapi/silverlight/2.1/help/Find_task.htm

But every time i clik the Find button i get this error:
Find error: ESRI.ArcGIS.Client.Tasks.ServiceException: Object not set to an instance of an object.

my c# code from the click event:
 
findTask = new FindTask("REMOVED HERE But Valid url used");
            findTask.ExecuteCompleted += new EventHandler<FindEventArgs>(findTask_ExecuteCompleted);
            findTask.Failed += new EventHandler<TaskFailedEventArgs>(findTask_Failed);

            FindParameters findParameters = new FindParameters();
            findParameters.LayerIds.AddRange(new int[] { 6, 8 }); //layer id for vejnavne
            findParameters.SearchFields.AddRange(new string[] { "VEJNAVN" });
            findParameters.ReturnGeometry = true;
            findParameters.SearchText = autoCompleteAdresse.Text.ToUpper();

            //debug data
            MyTextBlock.Text = findParameters.SearchFields[0].ToString() + " " + findParameters.SearchText + " " + findParameters.LayerIds.ToString() + findTask.Url;

            findTask.ExecuteAsync(findParameters);


Any idea whats is Wrong?
0 Kudos
11 Replies
DominiqueBroux
Esri Frequent Contributor
A first glance your code looks good.

I suggest that:

1) you verify that your service is working well by testing the 'Find' url : <mapServiceUrl>/Find
Example of Url with ArcGISServiceOnLine : http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/Map...

2) use fiddler to look at the requests sent by your silverlight application. Hopefully this will give a clue.
0 Kudos
MatthewCarey
Regular Contributor
Maybe you just slipped up in your cutting and pasting, but shouldn't the first line read:

FindTask findTask = new FindTask("REMOVED HERE But Valid url used");


Just in case.....
0 Kudos
TomJohnson
New Contributor
I'm having the same problem.  If I access the "find tool" directly from the REST url, it almost works.  The result information I get is:

# results: 1

59957S44858
    Feature ID: -1
    Field Name: Grid Number
    Layer: Pole


It doesn't return a proper Feature ID, any of the attributes, or the geometry (even though it was requested.)

Next, if I add "&f=json" to the end of the request to get a JSON response, the response I get is:
{"error":{"code":500,"message":"Object reference not set to an instance of an object.","details":[]}}.


There definitely seems to be something wrong on the server side here.  Has anybody been able to resolve this issue?  For some reason everything works on the ESRI sample map services.
0 Kudos
JenniferNery
Esri Regular Contributor
When you perform Find from your web browser, do you use the same parameters that your application use? Can you verify that these parameters are correct and both app and browser yield to same result? Please refer to post#14 from this thread to guide you on what to look for when running Fiddler with your app http://forums.arcgis.com/threads/14730-Area-And-Perimeter

Appending "&f=json" to the Url should not have caused this error. I tried the same here: http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/Map...
0 Kudos
EugeneChuguy
Emerging Contributor
Hi, a have a same problem. When i set the Direct Connect in project and restart service the Silverlight App send request like this
.../Find?searchText=11086&contains=true&returnGeometry=true&searchFields=OBJECTID&layers=1&f=json&

and i have an error
{"error":{"code":500,"message":"Object reference not set to an instance of an object.","details":[]}}

But when i try to send the request without parameter f=json i get expected result. Where is the solve?
0 Kudos
JenniferNery
Esri Regular Contributor
Have you tried creating the web request from your web browser? Error 500 is from the Service?

It's hard to suggest a fix. I don't understand the problem. Does it work if you don't append "&f=json"?
0 Kudos
JacobSaugmann
Deactivated User
Im still struggling with this problem, i get Object not set to instance of an object, or Error 500, the string looks ok(i use Firebug in Firefox)
this is the url
https://gis.verdo.dk/ArcGIS/rest/services/GRUNDKORT/GrundkortRDS/MapServer//Find?searchText=B%C3%B8sbrovej&contains=true&returnGeometry=true&searchFields=VEJNAVN&layers=8&f=json&


When i remove f=json&

the server returns 379 results all with the feature id = -1

Any idea??
0 Kudos
AliMirzabeigi
Emerging Contributor
If you are using ArcGIS 9.3 please make sure you have installed the latest service packs. The reason I'm suggesting this is that it looks like if the rows returned from your request contain some special characters like quote, double quote, etc... the REST request fails to return the results. More information on this thread: http://forums.arcgis.com/threads/11834-Error-500-with-JSON-in-Find-operation
0 Kudos
JacobSaugmann
Deactivated User
YES YES YES YES 😄

An upgrade to sp2 solved my problem 🙂

THANKS

Merry Christmas
0 Kudos