Tags: | Categories: Blog Posted by admin on 9/2/2009 6:47 AM | Comments (4)

If you haven’t please read part 1 before reading this post.

The most powerful thing about .NET RIA Services besides the whole framework, is the concept of sharing code from ASP.NET and Silverlight without extra steps and setting up Web Services manually. .NET RIA services provides you an automatic creation of the proxy classes to share the code between those 2 tiers.

.NET RIA Services is simple, yet introduces a few things for the developer to learn, I hope this simple tutorial will help learn those.

How to share new code.

We create a class on the ASP.NET tier.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace SilverlightApplicationRIA.Web.MyCode
    public class MyClass
        public string foo()
            return "Hello World";

Writing something so simple and compiling it will generate a proxy file in Silverlight to be created, the key is to name your classes with .shared in order for the .NET RIA Service to pick it up and generate the proxy class.

If we look into the Silverlight application will find hidden files in the project that you can see going to the Windows Explorer.



How to share existing code.

You can select an existing file and select to Add Link instead of just add to create the same file in both tiers.


This option is important to use existing items that you want to exist in both tiers, the physical files are not copied, it just creates a link between them in the hard disk.


How to share a library.

You can share .NET 3.5 libraries with Silverlight 3.0. This is what makes .NET RIA Services great, write it once, share it twice.


Consuming the shared code in Silverlight.

The pattern to consume the code in Silverlight from .NET RIA Services is pretty simple as if you remember there is a proxy copy on Silverlight created. So just add the correct namespace and execute the method synch not asynch like you would do in a web service for Silverlight.


public partial class MainPage : UserControl
        public MainPage()

            SilverlightApplicationRIA.Web.MyCode.MyClass myClass = new SilverlightApplicationRIA.Web.MyCode.MyClass();
            string sText = myClass.foo();

The sText will show a “Hello World” answer.


What about accessing to the ASP.NET Security.

I’ll cover this part extensively on part 3 of this series, yet to quickly answer the question of all of you that email me about this, you can in Silverlight consume the security context of the ASP.NET application by using the RiaContext class.


Happy .NET RIA Services coding.



Tags: | Categories: Blog Posted by admin on 8/28/2009 7:46 AM | Comments (3)

With the templates coming out of VS2008 when you create a Silverlight application, a ASP.NET Web project is created for you to test your Silverlight app that adds the control into a ASPX page and a HTML page. Many developers will use the power of ASP.NET for server side processing and add a few ASP.NET controls on the page where the Silverlight control is.

There is when the user will find the problem about mixing up server side controls and Silverlight, the server side controls will cause postbacks that will refresh the Silverlight control. To avoid that problem, the developer may want to use MS ASP.NET AJAX to avoid the server side controls from doing a postback using the UpdatePanel. For this to work there is a simple modification that you need to do at the page where you are hosting the Silverlight control.

First drag and drop the ScriptManager on the page.


Second replace the location of the Silverlight.js file from:

<script type="text/javascript" src="Silverlight.js"></script>


To be hosted inside the ScriptManager like this:

<asp:ScriptManager ID="ScriptManager1" runat="server">
           <asp:ScriptReference Path="Silverlight.js" />

Now all the controls hosted inside the UpdatePanels should work, remember not to add an UpdatePanel to wrap the Silverlight control.

Happy Silverlighting.



Follow me in twitter | bookmark me | Subscribe to my feed | Add stats to your blog

Tags: | Categories: Blog Posted by admin on 8/27/2009 6:43 PM | Comments (3)

For the past year I have been posting about .NET RIA Services and encouraging Silverlight developers to get started early in this framework for the Enterprise.

What’s is .NET RIA Services?

In very simple words is the complete story from Microsoft to bring ASP.NET and Silverlight and take advantage of the best of both worlds. Use each technology for what does best. As well as use patterns to write your solutions. For example, use ASP.NET for Authentication instead of Silverlight, yet Silverlight will take advantage of the security from ASP.NET. And MVC pattern for Silverlight as well not just ASP.NET.

Where do I start?

I would as a developer always start by getting my hands dirty, download the sample solution and look around the moving parts. The latest was posted by Microsoft on July 2009, still is not the release version yet I would recommend to start learning now. In the same page you can download the overview documentation for .NET RIA Services.

Where is the architecture graphic?

You cannot explain technology concepts anymore without a power point presentation or a great chart, so here is “the graphic”

From their Microsoft RIA Service Overview I “borrowed” “the graphic”


System Requirements

Windows 7; Windows Server 2003; Windows Server 2008; Windows Vista; Windows XP Service Pack 3

Visual Studio 2008 SP1 or Visual Web Developer Express 2008 SP1.

After the installation you’ll be able to select an option to Enable .NET RIA Services in Visual Studio 2008 SP 1


Make sure to check the box to start your solutions, by default the checkbox isn’t check.

If you have already a Silverlight solution that you would like to convert, you can do so by going to the projects properties, select the Silverlight and change the dropdown .NET RIA Services


From here is all making sure you can consume your data from the database and is easy to follow the pattern to display it in Silverlight.

How to share code between ASP.NET and Silverlight.

Generates a proxy file between ASP.NET and Silverlight from the Web Project to the Silverlight one, to be able to call the methods with transparency using attributes like EnableClientAccess will created for you without having to create a Web Service.


This is an opportunity for developers to start with a solution that will give you your server side and you client side communication for your enterprise solution in a clear and simple pattern for you to follow.



Tags: | Categories: Blog Posted by admin on 8/26/2009 11:28 AM | Comments (1)

Prior the release of Silverlight 3, the way to enable Silverlight to run out of the browser meant to edit the AppManifest.xml file and add this XML.   

        ShortName="Out of Browser Application"
        Title="This app is out of the browser!">
        Sample Out of the Browser App

Now that Silverlight 3 its being released, is much easier than that.

Go to the Silverlight properties then the Silverlight tab, there is a check box called Enable running application out of the browser, you can enable that and a new button called Out-of-Browser Settings will appear to set how you want the application to look.


A new file will show up under properties called OutOfBrowserSettings.xml



The XML generated will look like that:

<OutOfBrowserSettings ShortName="Application" EnableGPUAcceleration="True" ShowInstallMenuItem="True">
    <OutOfBrowserSettings.Blurb> Application on your desktop; at home, at work or on the go.</OutOfBrowserSettings.Blurb>
      <WindowSettings Title=" Application" />
    <OutOfBrowserSettings.Icons />

You can change the values on the file or use the UI to do so.

Happy coding.



Follow me in twitter | bookmark me | Subscribe to my feed | Add stats to your blog

Tags: | Categories: Blog Posted by admin on 8/26/2009 9:45 AM | Comments (0)

These are the new innovations that can help you be part of the new efficiency. And at our free live events, you can learn, network, and get your copy of Windows 7!

Register here:



07:30 AM - 9:00 AM

Developer Event Registration & Continental Breakfast

09:00 AM - 11:35 AM

Optimizing Your Application For Windows 7
See More

When running your application on Windows 7, do you feel it performs at its best? Do you want your application to shine on Windows 7 and give your users the comfort that comes with Windows 7 Taskbar and Libraries? This session can show you how to give your applications new functionality with very few code changes.

Creating New And Exciting Users Experiences – Part 1
See More

Do you want to differentiate yourself from the competition? Do you want to be able to say, "Hi, my app brings extra value on Windows 7." Then these sessions are for you! In the first of this two part series, you'll learn about these features and more:

  • Windows 7 Sensor and Location platform to optimize your mobile user's experiences
  • Windows Touch at your fingertips
Creating New And Exciting Users Experiences – Part 2
Tags: | Categories: Blog Posted by admin on 8/6/2009 3:17 PM | Comments (0)

Printing in REST? The most common question. The JavaScript API Team released this sample.

The first API that serializes the information to allow a webservice to print the image. The webservice is java based and can be download it here.


Hope this helps



Follow me in twitter | bookmark me | Subscribe to my feed | Add stats to your blog

Tags: | Categories: Blog Posted by admin on 8/5/2009 8:30 PM | Comments (0)

As every vacation I would like to share a few pictures from the time we had together. Was just great spending all that time with my kids without being interrupted by going to work ;-)


More pictures can be found in out flickr account.




Tags: | Categories: Blog Posted by admin on 7/27/2009 5:04 PM | Comments (0)


By now if you read my blog in a regular basis realized the posts you read this week were previously scheduled.
The experiment of being without Internet for 2 weeks back fired. If you do not know the story, I went on vacation to Mexico with my family, the resort does not have Internet. So I thought that will be great for me to completely disconnect from the web for that period of time instead of having my brain always thinking about work, twitter, emails coming in every minute and communication technology.
Well I didn’t make it, the resort got free wireless the week we arrived that is not up all the time, yet I was able to use it. Wife and I were able to watch some Netflix (with a help of a proxy to avoid the geographic restriction) and I just have check for the first time my email, amazing how many hundreds of emails queued up in one week. Luckily my folder system to prioritize emails on arrival filters what is important for my attention versus people just giving you an FYI.
I would like to note, I enjoyed keeping my iPhone in the safe to spend time with my kids without interruption and the freedom of kayaking around this great rivers around the resort. The 3 years old learned to swim, my oldest is learning Spanish and the baby, well the baby does not sees me as a stranger anymore.
So I think all geeks should turn off the Internet once in a while.
PS. I have amazing post coming up about this Eco Park with picture that you won’t believe. I’ll post upon my arrival next week.
Tags: | Categories: Blog Posted by admin on 7/17/2009 10:53 AM | Comments (0)

Playing a little with SQL 2008 geometry I thought to post the queries that insert point, lines and polygons for the world to copy and paste if you like

INSERT INTO [Test].[dbo].[GeometryTest]
           ,'POLYGON ((5 4, 5.38924515247345 4.0785849690437317, 5.70710676908493 4.29289323091507, 5.9214150309562683 4.61075484752655, 6 5, 5.9214150309562683 5.38924515247345, 5.70710676908493 5.70710676908493, 5.38924515247345 5.9214150309562683, 5 6, 4.61075484752655 5.9214150309562683, 4.29289323091507 5.70710676908493, 4.0785849690437317 5.38924515247345, 4 5, 4.0785849690437317 4.61075484752655, 4.29289323091507 4.29289323091507, 4.61075484752655 4.0785849690437317, 5 4))')


Adding a Spatial Reference to the polygon with automatic convertion.

INSERT INTO [Test].[dbo].[GeometryTest] values ('Polygon2', geometry::STGeomFromText(
'POLYGON((-122.358 47.653, -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326));


INSERT INTO [Test].[dbo].[GeometryTest] values ('Line', geometry::STGeomFromText(
'LINESTRING(-122.34799999 47.648999999, -122.34799999999814 47.658000000054017, -122.35 47.65800, -122.35800000000745 47.652999999932945, -123.999 44.999)', 4326));


Create a buffer from a geometry

SELECT     TOP (1) Shape.STBuffer(0.001) AS Expr1
FROM         dbo.GeometryTest

Get a centroid

SELECT     TOP (1) Shape.STCentroid() AS Expr1
FROM         dbo.GeometryTest

Get the boundary

SELECT     TOP (1) Shape.STBoundary() AS Expr1
FROM         dbo.GeometryTest





Tags: | Categories: Blog Posted by admin on 7/14/2009 1:18 PM | Comments (2)

ESRI released the Toolkit for the ArcGIS Silverlight at codeplex for all users to be able to download the source code.

Go and download the source code here.

Project Description
This project contains the source code and libraries for the ESRI ArcGIS Silverlight Toolkit SDK. The library is an extension of the ArcGIS API for Microsoft Silverlight™/WPF™. Included are a number of controls, widgets and tools that you can use to enhance your web applications.

NOTE: This library is only an extension of the ArcGIS API for Microsoft Silverlight™/WPF™, so in order to build a complete web mapping application, you will also need the ArcGIS API for Microsoft Silverlight™/WPF™. See below for download instructions.