Click here to Skip to main content
Sign Up to vote bad
good
See more: WCFSilverlightRIA
Hi guys,
 
I had a domain services (build in Silverlight Business Application Web) the Silverlight App local (e.g TestAppSilverlight and TestAppSilverlight.Web) is ok which I can implement CRUD method. (but I can't async this app !!!)
 
But when I deploy this domain services via SOAP-ODATA-JSON for another Silverlight App ,i got big problem when implement this service (with SOAP-VS 2010 debug some error inside the sevice,with ODATA-JSON are ok) and when I retrieve some record (via ODTA-JSON) i got message from IE like that :
===========
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E) Timestamp: Wed, 20 Apr 2011 03:27:25 UTC
Message: Unhandled Error in Silverlight Application Silverlight does not enable you to directly enumerate over a data service query. This is because enumeration automatically sends a synchronous request to the data service. Because Silverlight only supports asynchronous operations, you must instead call the BeginExecute and EndExecute methods to obtain a query result that supports enumeration. at System.Data.Services.Client.DataServiceQuery1.System.Collections.Generic.IEnumerable<TElement>.GetEnumerator() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) at SilverlightClient.MainPage..ctor() at SilverlightClient.App.Application_Startup(Object sender, StartupEventArgs e) at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args) at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName) Line: 1 Char: 1 Code: 0
================
What should I do now Frown | :( ?
Please help me.
Posted 20 Apr '11 - 0:16
Edited 20 Apr '11 - 4:13

Comments
Mark Salsbery - 8 Jul '11 - 12:34
This doesn't look like a sync/async issue at all. It looks like you are trying to execute code on the client which should be done on the server end.

2 solutions

You can't enumerate (do a foreach) on some collection.
 
Try doing a "var myNewCollection = yourCollection.ToList();" first and enumerate on that.
  Permalink  
Comments
Kenny Woo - 22 Apr '11 - 11:16
Not simple like that. Do you know you must do sync or async for this problem? I posted on .NET 4rum and some technician helped me resolve that problem (you can see more here http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/1ce9a4d1-4a30-44ae-83de-be6661cd4829 ) But i still confuse when develop CRUD (Retrieve is Ok) for Silverlight Client WCF RIA ( not for the Silverlight Client with same solution of Domain Service - it's simple!)
orsobrown - 22 Apr '11 - 11:46
The problem under the hood is that Silverlight can't call web services synchronously. You must access the service asynchronously. Have a look here for example http://msdn.microsoft.com/en-us/library/ms730059.aspx
Kenny Woo - 22 Apr '11 - 12:14
Yes. I follow this link to resolve that call service synchronously and add the clientaccesspolicy.xml to client app. Can you give me some sample for CRUD synchronously. Thanks
orsobrown - 22 Apr '11 - 12:35
Probably, it's me... to my knowledge, you can't call any SOAP service from a Silverlight client in a synchronous way. But someone says you can: http://www.codeproject.com/KB/silverlight/SynchronousSilverlight.aspx read his article, try his code and/or ask him directly
Kenny Woo - 22 Apr '11 - 21:37
I agree with you - i can't call any method from my Domain Service for CRUD function . Thanks for your advice.
<strike><strike><strike><strike><small><big><pre><code><code>&lt;&amp;<a href=""></a><a href=""></a>[<a href="" target="_blank"></a>]</code></code></pre></big></small></strike></strike></strike></strike>
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 353
1 Sergey Alexandrovich Kryukov 138
2 Mohammed Hameed 123
3 Santhosh G_ 113
4 Ron Beyer 64
0 Sergey Alexandrovich Kryukov 8,266
1 OriginalGriff 6,516
2 CPallini 3,533
3 Rohan Leuva 2,703
4 Maciej Los 2,234


Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 7 Jul 2011
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid