Click here to Skip to main content
15,885,309 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :( ?
Please help me.
Posted
Updated 20-Apr-11 4:13am
v2
Comments
Mark Salsbery 8-Jul-11 12:34pm    
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.

<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>
 
Share this answer
 
You can't enumerate (do a foreach) on some collection.

Try doing a "var myNewCollection = yourCollection.ToList();" first and enumerate on that.
 
Share this answer
 
Comments
appxdev 22-Apr-11 11:16am    
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!)
Bruno Tagliapietra 22-Apr-11 11:46am    
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
appxdev 22-Apr-11 12:14pm    
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
Bruno Tagliapietra 22-Apr-11 12:35pm    
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
appxdev 22-Apr-11 21:37pm    
I agree with you - i can't call any method from my Domain Service for CRUD function .
Thanks for your advice.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900