Click here to Skip to main content
11,409,922 members (48,269 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: WCF Silverlight RIA
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 1:16am
Edited 20-Apr-11 5:13am
Mark Salsbery at 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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

<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>
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can't enumerate (do a foreach) on some collection.

Try doing a "var myNewCollection = yourCollection.ToList();" first and enumerate on that.
Kenny Woo at 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 )
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 at 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
Kenny Woo at 22-Apr-11 12:14pm
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.
orsobrown at 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:

read his article, try his code and/or ask him directly
Kenny Woo at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 270
1 OriginalGriff 255
2 Maciej Los 138
3 Andy Lanng 105
4 Sascha Lefévre 95
0 Sergey Alexandrovich Kryukov 8,771
1 OriginalGriff 6,905
2 Maciej Los 3,390
3 Abhinav S 3,248
4 Peter Leow 3,059

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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100