| Comments

In a previous post I wanted to call attention to the multi-targeting and design surface improvements for Silverlight developers with Visual Studio 2010 Beta 1.  There has been some comments on that post and a few emails and Twitter replies as well with some great follow-up questions.  I thought I’d post a sort of what works with what information to help you navigate Betaville as a Silverlight developer.

NOTE: We’re talking about Beta technologies here.  That means things may not work, that you shouldn’t count on them for production releases at this time, etc.  In the ‘release early, release often’ mantra of things, I know Microsoft may not follow the ‘often’ side of things, but we sure do release early a lot of things.  It is important to have a perspective that this is for mutual benefit, but also remember that it is beta and things may just not work in harmony.

Being an early adopter usually means you are on the edge.  Standing on that edge of technology comes pain with betas at times.  Add to that multiple beta technologies and you may feel like you are pulling your hair out constantly.  Me too.  Here’s the spectrum of things for a Silverlight developer from a current (as of May 2009) perspective.

Silverlight 2 Development

Silverlight 2 has been released for a while now (since Oct 2008) and is production-ready for you to use.  There is full tool support in both Visual Studio 2008 SP1 (just install the Silverlight tools for VS2008) and Blend 2 SP1.  Both VS2008 and Blend 2 can share project files in harmony and edit back and forth.

The recent Visual Studio 2010 Beta 1 (referred to in this post VS10 so I don’t have to keep typing out beta) will also support Silverlight 2 development.  The Silverlight tools will not install on top of VS10 and you’ll get a warning if you try.  If all you want is Silverlight 2 development in VS10 right now, install the Silverlight 2 SDK and the Silverlight 2 developer runtime.  That’s it…you can then develop Silverlight 2 applications.

Silverlight 3 Development

Silverlight 3 is currently in beta as are the associated tools (Silverlight 3 tools for VS2008 and Blend 3).  A lot of people have been working fine with these in beta and everything works well.  VS2008 can author SL3 projects and Blend 3 can open them no problem.  Both of these are still in beta right now, but it is important to know that Silverlight 3 release tools will be VS2008 and Blend 3.

For VS10 and Silverlight 3, the situation with the tools is similar to Silverlight 2.  The Silverlight tools installer will still not run on VS10.  If you want to add Silverlight 3 development to your VS10 environment, you can follow my previous post instructions, which basically is to install the SL3 SDK and SL3 developer runtime.  At this time, VS10 will only target Silverlight 3 beta and will also not run the .NET RIA Services bits that you might be using.

What about Blend and Visual Studio 2010 Beta 1?

With VS10 there are some caveats.  With VS10 you can create multi-target solutions.  You can see this when you create a new project in VS10:

Visual Studio 10 multi-targeting

Now for the caveat.  If you select .NET Framework 4 in VS10, and then open your project in Blend 2 you will see this warning:

Blend warning on opening VS10 solution file

In my experience under simple circumstances you can still open it and work with files.  Here’s where beta life starts getting confusing.  If your Silverlight application is just the application, you will see the above warnings and should be able to edit (regardless of if your target in the new project window was .NET Framework 4 or 3.5).  Now, if you also added a web project to your solution and open it in Blend 3 Preview, you will see this:

Blend warning on opening up .NET 4 project

Indicating that the web project type is not supported at this time in Blend 3.  The solution will open in blend (if you say yes) but your web project will have a “?” next to it and read (unsupported project).  You’ll still be able to edit the Silverlight application, but not do anything with the web project.

What about WPF projects then?!

If your target selection was .NET Framework 3.5 then you’ll still get the first warning, but should be able to work with the project.  If your target selection was .NET Framework 4, then you’ll get the unsupported warning and won’t be able to work with this.  Oddly enough, Blend 2 will open the .NET 4 project, weird.  In either route, when you compile in blend you’ll see this note:

   1: Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild.  
   2: Treating the project as if it had ToolsVersion="3.5".

That should tell you something if you think Blend 2 is going to build your .NET 4 project just because it will open :-).

Why is it this way and when will it all work?

Ah, the magic crystal ball.  If we could get all the teams on the same ship cycle it would be easy, but it just isn’t that way right now.  Basically VS10 went into beta 1 lockdown before certain things for Silverlight and Blend tools were able to hit certain milestones.  So given that, here’s where we stand.

NOTE: Expression Encoder outputs either Silverlight 1.0 or Silverlight 2 templates and the output are completed projects.  If you open up the source for an Encoder project it will prompt the VS10 upgrade wizard, or in VS2008 just open for you to edit (assuming you have the Silverlight tools installed)

For Blend 3 and VS10 projects to work in harmony, an update to the Expression Blend 3 preview that supports Visual Studio 2010 and .NET Framework 4 projects is expected to be available in Q3 of 2009.

For VS10 and Silverlight 3 RTW/.NET RIA Services working, we’re looking at an update to VS10 would be needed and we haven’t determined a timeframe on that just yet.

What should I do?

Well, as a Silverlight developer, I’ve given my opinion already.  Until that update for VS10 happens to enable Silverlight 3 RTW and .NET RIA Services development, I think the best option will still be the released tools for the environment (VS2008, Blend 3).  Consider VS10 something to look at, but not ready just yet for full Silverlight 3 development.

For other project types like ASP.NET, WPF, WinForms, etc. you’ll still be able to multi-target in VS10 and most of these are released right now so you should be in a decent environment.  WPF caveats above still apply as most WPF developers also rely on Blend as a tool for their projects.

Summary

I know this is totally confusing and it sucks.  After re-reading this, my own head spins.  It is easy for us to say it is the pain of an early adopter…and it is.  By sitting on the edge with beta technologies we take risks and have to determine our own rewards.  Knowing this information should help you be informed about your projects.

  • Silverlight 2 + VS2008 + Blend 2 development: released, available, working
  • Silverlight 2 + VS10 + Blend 2 development: available, working (VS10 in beta)
  • Silverlight 3 + VS2008 + Blend 3 development: available, working (Silverlight 3 and Blend 3 in beta)
  • Silverlight 3 + VS10 + Blend 3 development: available, working with caveats (Silverlight 3 beta only, no RIA services)
  • WPF + VS10 + Blend 3 development: available, caveat of Blend 3 will not open .NET 4 projects from VS10

Remember, virtual machines can be your friend!  For some more general Visual Studio 2010 and .NET 4 training information check out the training kit here.  For information regarding ASP.NET MVC and VS10, check out Phil’s post.  Hope this helps!

| Comments

Well today was the public release of Visual Studio 2010 Beta 1.  It is the first time developers will have the chance to take it for a spin and kick the tires.  I wanted to share some information specific for Silverlight developers with regard to Visual Studio 2010 Beta 1.

Visual Studio 2010 is the first IDE that will support two key features for Silverlight developers: multi-targeted Silverlight development and editable design surface for Silverlight.  The second point also comes with things you might expect (like data binding wizards and dialogs as well – I’m lumping all of that in to ‘editable design surface’).  To get started there are a few things you should know.

First, if you are installing from a “clean” environment (perhaps a virtual machine, etc.) and want the multi-target support, here’s what you’ll do:

  1. Install Visual Studio 2010 Beta 1
  2. Install Silverlight 2 SDK (if you attempt to run the Silverlight 2 tools installer it will fail with an error message…just install the SDK).
  3. Install Silverlight 3 Beta SDK (again, don’t attempt the tools installer as it will fail)
  4. Install Silverlight 3 Beta Developer Runtime

Once you have done this, you now have a Silverlight 2 and 3 development machine for Visual Studio 2010 Beta 1.  Congratulations!

Hey, where’s my multi-targeting?!

Be patient.  When you create a new project you’ll see just the standard Silverlight application templates.  Select that first and then you will see the multi-target option in the next dialog:

Visual Studio 2010 Silverlight multi-targeting

Once you select this option you will be starting development using that runtime version.  So remember, it is after you select a Silverlight project type.  If you want to change the target version runtime after you’ve created a project, just right-click on the Silverlight project, choose the properties and you’ll see Target Silverlight Version and can change it there.

What about the editable design surface?

Once you have a Silverlight project ready, you can use the design surface for editing and dragging/dropping UI elements, arranging layout, etc.:

You can also now select items on the design surface and manipulate binding or other properties in the ‘normal’ Visual Studio way (property panes, dialogs).

Hey, what happened to my Silverlight Templates…and what about .NET RIA Services?!

For right now in Visual Studio 2010 Beta 1, the Silverlight Navigation Application template is not available as a part of the SDK installer (it’s actually a part of the tools installer…which you can’t run for VS2010 Beta 1).  If you want that template, just export one from Visual Studio 2008 and import it into this environment.  It will then show up under the My Templates section.

.NET RIA Services also will not install for VS2010 Beta 1 right now.  So if you want to play around with those bits, stick to VS2008 SP1.

Both of these are known and will be resolved in the future.  Hopefully you understand that the products are in varying beta stages (VS2010, Silverlight 3 and RIA Services) and are not in sync right now.  Kind of a pain, but it’s the sting of early adoption I suppose.

My Recommendation

So what should you do?  Well I do think you should try Visual Studio 2010 and play around with it.  If you need RIA Services development, then stick with Visual Studio 2008.  If you have the ability to run a second machine or a virtual machine, I recommend putting Visual Studio 2010 in that environment.  For Silverlight 3 we will be targeting VS2008 SP1 for release.  Obviously the team is working on supporting VS2010, but for beta 1, we just couldn’t get it in time.  So I’d personally recommend sticking with VS2008 as your primary dev environment for all Silverlight 3 goodness…and run VS2010 in a separate space to play around with. 

Hope this helps!

| Comments

I’ve not hidden my love affair for Netflix both as a consumer and as a Silverlight developer and how they’ve implemented the technology.  Long before the instant watch came to the desktop and the XBOX, there were a lot of folks wanting the Netflix experience on their Windows Media Center boxes and extenders.  One such person was Anthony Park (who is now with Netflix as of this writing), who picked up a the MyNetflix media center plugin a while back.

Well, today Netflix officially has a Media Center solution for their customers.  I just got done firing my media center machine up and started the process of getting Netflix on the box.  It showed up under the Program Library and I followed the minimal instructions to get it working…restarted Media Center (not the machine) and boom, done.  I love how the branded experience of their application matches their online app as well as their overall brand identity very well:

Netflix Media Center Login

After logging in, I’m able to view my Instant Queue, DVD Queue, genre’s and new releases. 

Netflix Media Center DVD Queue

Once I find a movie from one of the categories not in my queues, I can even add it at that point!  Nice!

Netflix Media Center Add to Queue

Once you choose to watch a movie through the experience, you’ll notice something familiar – yep, that’s Silverlight powering the playback of the Netflix Instant Watch feature in Media Center.  Nice.  This is a great continuum story for the platform and for Netflix to be able to re-use their platform and their custom implementations in various areas: online (browser), XBOX, and Media Center.  Very cool to see this.  I still think the coolest feature of Instant Watch is how all the experiences are synchronized…I can pause anywhere and pick up another medium (XBOX) and start where I left off – awesome.

NOTE: It looks like at this time it is Media Center for Vista only and Windows 7 RC machines are not enabled.  Additionally, I am guessing that the same licensing rules apply for the media content, so probably only US customers. 

Kudos to the Netflix team for enabling this feature and extending their reach to where (and how) people want to view their media.  If you want to figure out how to enable it on your media center machine, you can watch this video (just try to disregard the creepy mitten-wearing hands…odd): Get Netflix on your Media Center.

| Comments

For things that aren’t a part of the Visual Studio tools (yet) and things that help me move faster in my development, I like to take advantage of the power of Visual Studio’s templates and snippets capabilities.  I’ve created a few and modified a few of others that I use regularly.  I’ve shown them in a few presentations and thought I’d package them up in a single bundle for your convenience if you choose to use them.  I was going to package Robby’s snippets up as well, but didn’t think he’d appreciate that…you should get his Silverlight snippets as well (and he’s packaged them in a VS community installer also).

Here’s the ones that I have in my package right now:

  • FloatableWindow item template – this is from my adaptation of ChildWindow.  You’ll of course need the binary for this to make any sense as well.
  • Silverlight Pixel Shader item template – adapted from the WPF template, with making the minor adjustments needed by default to make it work in one shot.
  • ResourceDictionary item template – using Nick Kramer’s base for adding stand alone ResourceDictionary files to your project (to take advantage of the merged resource feature in Silverlight 3).
  • Cross-domain policy file item template – rapidly add one just like you would web.config.  You still have to set the desired security – I chose not to imply one for you :-)
  • Cross-domain policy code snippet – this actually goes along with the policy file (or replacement) which is a VS code snippet template if you want to just use that instead

I’m sure I’ll add more over time and package it in this update but for now this is what I could pull together.  Sorry the package isn’t signed as a verified publisher…if I could figure out how to do that I would have tried :-).  You can download them here: SilverlightVSHelpers_1.vsi.  Oh and yes, they are for Visual Basic and C#.

Hope this helps!


This work is licensed under a Creative Commons Attribution By license.

| Comments

We’ve update the .NET RIA Services build for May 2009.  The updated May preview can be downloaded here: .NET RIA Services May 2009.  You may have to uninstall your previous version before installing this one. 

What is .NET RIA Services?
Microsoft .NET RIA Services simplifies the traditional n-tier application pattern by bringing together the ASP.NET and Silverlight platforms. The RIA Services provides a pattern to write application logic that runs on the mid-tier and controls access to data for queries, changes and custom operations. It also provides end-to-end support for common tasks such as data validation, authentication and roles by integrating with Silverlight components on the client and ASP.NET on the mid-tier.

This update incorporates a bunch of fixes that have been reported in the RIA Services forum.  This is a good place to report issues and communicate with the dev team.  Most fixes came from the forum.  In addition, DomainService base classes now infer some data access metadata based on the model (length, required for example).  There are a few other samples that were added to this as well to note:

Also upon installing you’ll see a new project type called the Business Application Template.  Right now it looks and feels exactly like the navigation template with the Silverlight tools, but has a few defaults added, namely authentication.  You’ll see in the ASP.NET project there with a Services folder and three new files: AuthenticationService, UserInformation, UserRegistrationService.  These are all services to expose authentication and membership integration.  Running the template by default will give you a new “login” link in the upper right and clicking on that implements a new ChildWindow for login:

Biz App Login Template

Notice the "Register now” link which then uses another ChildWindow control for registration:

Biz App Register Template

Registering a new user uses the UserRegistrationService to add a new user to the system.  If you look at the UserRegistrationService you’ll see that it uses the ASP.NET Membership APIs:

   1: namespace BusinessApplication2.Web
   2: {
   3:     [EnableClientAccess]
   4:     public class UserRegistrationService : DomainService
   5:     {
   6:         // NOTE: This is a sample code to get your application started. In the production code you would 
   7:         // want to provide a mitigation against a denial of service attack by providing CAPTCHA 
   8:         // control functionality or verifying user's email address.
   9:  
  10:         public void AddUser(UserInformation user)
  11:         {
  12:             MembershipCreateStatus createStatus;
  13:  
  14:             // NOTE: ASP.NET by default uses SQL Server Express to create the user database. 
  15:             // CreateUser will fail if you do not have SQL Server Express installed.
  16:  
  17:             Membership.CreateUser(user.UserName, user.Password, user.Email, user.Question, user.Answer, true, null, out createStatus);
  18:             if (createStatus != MembershipCreateStatus.Success)
  19:             {
  20:                 throw new DomainServiceException(ErrorCodeToString(createStatus));
  21:             }
  22:         }
  23:         
  24:         // other methods exist here
  25:         // ...
  26:     }
  27: }

Because the membership APIs are provider-based, you can leverage whatever you want for your membership model and still use those APIs.  The example uses the default mechanism in ASP.NET.

Download the updated RIA Services bits today and take a look at the new template for integrating with the various ASP.NET providers.  Thanks for the continued feedback and keep it coming!