Skip to main content
Home Forums Silverlight Programming Accessing Web Services with Silverlight Web Services Error on List<string> after upgrading from Silverlight 2 Beta 2 to Silverlight 3
12 replies. Latest Post by salosa on November 4, 2009.
(0)
salosa
Member
3 points
24 Posts
10-18-2009 10:21 AM |
Hi there,
Currently I'm having this crazy web services error. I have zero background on the web services and the web services that I'm using right now was created by someone else.
The web services is working when my project was in Silverlight 2 Beta 2. But once I've upgrade my silverlight to Silverlight 3, then it has this error occurred. The error happened when trying to pass a List<string> from Web Services to my Overview.xaml. The error message that I found in Fiddler is: Object reference not set to an instance of an object.
In my overview.xaml, I have code as below to call the web services.WCFListofValues.WCFListofValuesClient ddlListClient = new Depot.WCFListofValues.WCFListofValuesClient();ddlListClient.GetStateListCompleted += new EventHandler<Depot.WCFListofValues.GetStateListCompletedEventArgs>(ddlListClient_GetStateListCompleted); ddlListClient.GetStateListAsync();void ddlListClient_GetStateListCompleted(object sender, Depot.WCFListofValues.GetStateListCompletedEventArgs e){ var asmxStateList = e.Result; for (int i = 1; i < asmxStateList.Count; i++) { ddlOverviewState.Items.Add(asmxStateList.ToString()); } ddlOverviewState.UpdateLayout(); ddlOverviewState.SelectedIndex = 0;}
Below are my project print screens. Hope they are clear enough. Please do help me as I've spent a week to solve this out. I really don't know anything on web services. I don't get it why it cannot pass the List<string> from web services right after I upgrade my project to Silverlight 3. Thanks a lot!
Depot Solutions
WCFListofValues.svc.csIWCFListofValues.cs
MarkMonster
Contributor
5220 points
1,046 Posts
10-18-2009 2:43 PM |
Hmm, very strange. Did you try updating the web/service reference in the Silverlight project? Also can you show a little bit more on the error, like the stacktrace? That will probably help very much.
10-19-2009 5:19 AM |
Hi Mark,Thanks for the quick reply. Yes, I've updated my web service reference in the Silverlight project. I've even deleted and re-added it again. But still the same problem. :( Below is the stacktrace of the error message. Please let me know if you need further detail on the error. I really have no idea on the web services. Once again, thanks!System.ServiceModel.CommunicationException was unhandled by user code Message="The remote server returned an error: NotFound." StackTrace: at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) at System.ServiceModel.ClientBase`1.ChannelBase`1.EndInvoke(String methodName, Object[] args, IAsyncResult result) at Depot.WCFListofValues.WCFListofValuesClient.WCFListofValuesClientChannel.EndGetStateList(IAsyncResult result) at Depot.WCFListofValues.WCFListofValuesClient.Depot.WCFListofValues.IWCFListofValues.EndGetStateList(IAsyncResult result) at Depot.WCFListofValues.WCFListofValuesClient.OnEndGetStateList(IAsyncResult result) at System.ServiceModel.ClientBase`1.OnAsyncCallCompleted(IAsyncResult result) InnerException: System.Net.WebException Message="The remote server returned an error: NotFound." StackTrace: at System.Net.Browser.AsyncHelper.BeginOnUI(SendOrPostCallback beginMethod, Object state) at System.Net.Browser.BrowserHttpWebRequest.EndGetResponse(IAsyncResult asyncResult) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse(IAsyncResult result) InnerException: System.Net.WebException Message="The remote server returned an error: NotFound." StackTrace: at System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse(IAsyncResult asyncResult) at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClass5.<EndGetResponse>b__4(Object sendState) at System.Net.Browser.AsyncHelper.<>c__DisplayClass2.<BeginOnUI>b__0(Object sendState) InnerException:
10-19-2009 5:25 AM |
Looks like the url that's configured to access the WebService isn't working anymore. Did you try accessing the url that you use to access the WebService through your web browser?
10-19-2009 5:42 AM |
Hi Mark,
You mean like using this url: http://localhost:51904/WCFListofValues.svcSorry, I'm not so sure how to test the web services.
10-19-2009 7:25 AM |
Do you have a ServiceReferences.ClientConfig file? And what are the contents?
10-19-2009 9:51 AM |
Here is my ServiceReferences.ClientConfig
10-19-2009 1:58 PM |
Can you remove the "." after localhost? I'm not sure if it helps, but please try it.
10-20-2009 4:25 AM |
The error still there after removing the "."
10-20-2009 4:51 AM |
Hmm, strange, I'm out of ideas, maybe someone else knows what the problem could be.
ashurocks
50 points
27 Posts
10-20-2009 5:22 AM |
Hi Sal ,
Before suggesting u anything just i would like to make sure some thing
Just after right click on service reference go to configure service refernece and then set collection type to generics.List
I Can suggest u two solutions
The code i have reviewed u r using List<string>.
1. Try Using List<String> as string is C# datatype and String is dotnetFramwork Datatype. Hope this can rectify ur problem .
2. Otherwise the Way Around solution to this problem is create a class having property List<string> in WCF service and the specifying the return type as that Class object.
Make Sure when tring to pass object between WCF and silverlight, the object class should be of WCF service only otherwise u will get exception.
Hope This work Out for U
10-25-2009 9:54 PM |
ashurocks,
sorry for late replying.
thanks for the solutions. I've tried them. but bad news...still the same error..
11-04-2009 11:57 PM |
Finally, I got it solved.I have to remove all the related web services files in my silverlight project, this included the ServiceReferences.ClientConfig. Then I re-added everything again and it works!