Astoria and Silverlight Integration Story

Here is my ideal scenario:

I'm in a Visual Studio Orcas solution. One project in that solution is my Silverlight application. Another is an ASP.NET application. I right click the solution and create a new EDM class library. Add a reference to that from my ASP.NET application, right click the ASP.NET application and add a new "Web Data Service" (Astoria).

Then, I right-click my Silverlight application and add a new item that is a strongly-typed client library that uses theBrowserWebRequest object underneath to give me access via REST and XML to the Astoria service.

How far are we from this kind of situation? I know that all of the Astoria stuff is available, and I know that Silverilght on its own can "go naked" to an Astoria service provided its not cross-domain, so the only bit that's missing is the client library and strongly-typed objects wrapping the service data.

Any idea on whether we'll see this kind of integration story in Beta 2?

[1049 byte] By [KevinHoffman] at [2008-1-25]
# 1

Hi Kevin,

Great question. We didn't have more content about this in the CTP documents because the actual bits weren't there.

Where we are right now: this works in my computer Smile. This boils down to having a custom build of the client library that uses the BrowserWebRequest and is adjusted for a few other differences in the Silverlight libraries. We just didn't have it ready in time for the CTP.

We'll see if we can find a way of shipping this out of band so you can try it by just adding the dll to your Silverlight install.

So how far: we're really close for a CTP-quality version of it, as soon as I find a delivery mechanism I'll see if it is possible to make it available.

Pablo Castro

Technical Lead

Microsoft Corporation

http://blogs.msdn.com/pablo

PabloCastro-MSFT at 2007-9-26 > top of Msdn Tech,Incubation Technologies,Project Codename: Astoria...
# 2
One delivery mechanism I might suggest would be e-mail. You can e-mail me the DLL Smile
KevinHoffman at 2007-9-26 > top of Msdn Tech,Incubation Technologies,Project Codename: Astoria...
# 3

Hi Pablo,

I would be really interested in seeing this scenario working. Any news on the possibilities to ship a Silverlight version of the Astoria client library?

Serge van den Oever [Macaw]
http://weblogs.asp.net/soever

SergevandenOever-Macaw at 2007-9-26 > top of Msdn Tech,Incubation Technologies,Project Codename: Astoria...
# 4

I'm attempting to do this manually at the moment.

I have a class library containing an EDM. I have a Silverlight application. I have an ASP.NET application (HTTP mode) that has a Silverlight link. The Silverlight application works fine against a local POX service that I wrote. What I want to do now is remove the dummy POX service and replace it with an Astoria "Web Data Service".

The problem is this: when I right-click my ASP.NET application, I don't get the option to create a Web Data Service. I know this has been there in the past, and it's there on brand new projects... is it forbidden on projects with a Silverlight link?

Is there something manual that I can do in order to enable this?

Bottom line : Silverlight means the most to me only when consuming data services, so the Silverlight + Astoria scenario is my critical scenario.

KevinHoffman at 2007-9-26 > top of Msdn Tech,Incubation Technologies,Project Codename: Astoria...
# 5

Hi,

It's not "forbidden"...in fact it is one of the primary scenarios for Astoria, along with the AJAX front-end one. This is probably just a glitch in the Astoria VS item template.

I'll track this and make sure we don't have the issue in the next iteration.

In the meanwhile, an easy work around is to create a separate, new "regular" ASP.NET (using File -> New Project and then choosing web app, *not* using File -> New Website); then create the EDM stuff in the project that is the same as in the project you already have, and then create the Astoria service. The output of the Astoria service item template is a .svc file, a .svc.cs (or .svc.vb) file, and an entry in web.config that configures WCF to work in compat mode. Simply import the two files and copy the web.config change into your initial project and you should be up and running.

If it doesn't work please let me know and I'll be happy to look into it in more detail, or even setup it up for you if you don't mind sharing a small subset of the VS project.

btw - While I'm late with this, we'll enable the Astoria client to run inside Silverlight. That means that you'll be able to run clientedmgen.exe, generate your client classes (or use your own), and then use a nice, object-based API in Silverlight, and we'll do the HTTP and serialization work under the covers for you.

Pablo Castro

Technical Lead

Microsoft Corporation

http://blogs.msdn.com/pablo

PabloCastro-MSFT at 2007-9-26 > top of Msdn Tech,Incubation Technologies,Project Codename: Astoria...
# 6

Pablo,

Can you throw something hard at me the day you folks come out with the Silverlight Astoria client? It'd be like Christmas Day for me, only better, and non-denominational! Smile

I'll give your workaround a shot and see what I get. Thanks!

KevinHoffman at 2007-9-26 > top of Msdn Tech,Incubation Technologies,Project Codename: Astoria...
# 7

Ok, so I got this scenario working. I have a Silverlight application, launched from TestPage.html. This page has a "button" on it (a clickable Canvas). When you click the canvas (MouseLeftButtonUp), it then goes and creates a BrowserWebHttpRequest instance based on the URI of the service and the list of entities I want ( localhost/myservice.svc/Ledger ). Then, it asynchronously retrieves the data from the background and all is well.

Here's the rub. When I set my label text to "Processing..." , I see nothing. However, when the thread.sleep (simulating large data access) finishes, I see the "Processed..." message. In other words, before the async call the GUI doesn't update, but after the async call, the GUI updates fine. I'm sure that my Thread.Sleep() call is blocking the GUI update, but the Async POX sample from the Silverlight quick starts does this same technique. When I run this sample, I get the same behavior... I see the "Calling ..... blahblah ..." only after the thread.sleep has taken place. Is this a bug, or something I need to work around somehow?

p.s. I know this is mostly a Silverlight question, but I figured I would try here first since I ran into this problem when building an Astoria service.

KevinHoffman at 2007-9-26 > top of Msdn Tech,Incubation Technologies,Project Codename: Astoria...
# 8

Here's a link to my blog post showing the steps I took to build the app and a screenshot of the GUI of a Silverlight application rendering data retrieved from Astoria.

http://dotnetaddict.dotnetdevelopersjournal.com/silverlight_astoria.htm

KevinHoffman at 2007-9-26 > top of Msdn Tech,Incubation Technologies,Project Codename: Astoria...
# 9

Here is a completely shot-in-the-dark theory: Thread.Sleep maybe pumping windows messages before/after/during sleep in order to be a better WinForms or COM citizen. I'm not in the office so I can't look at the code now, but that's likely why Sleep causes the UI to refresh. You can try forcing a refresh by calling refresh on the form.

Pablo Castro

Technical Lead

Microsoft Corporation

http://blogs.msdn.com/pablo

PabloCastro-MSFT at 2007-9-26 > top of Msdn Tech,Incubation Technologies,Project Codename: Astoria...