Click here to Skip to main content
Rate this: bad
good
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
appxdev1.2K
Edited 20-Apr-11 5:13am
v2
Comments
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
good
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>
  Permalink  
Rate this: bad
good
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.
  Permalink  
Comments
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 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 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 http://msdn.microsoft.com/en-us/library/ms730059.aspx
Kenny Woo at 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
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:
http://www.codeproject.com/KB/silverlight/SynchronousSilverlight.aspx
 
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 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Afzaal Ahmad Zeeshan 82
4 Sergey Alexandrovich Kryukov 75
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 7 Jul 2011
Copyright © CodeProject, 1999-2014
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