.NET Web Roadmap for 3.5 (ASP.NET, Silverlight, IIS 7)

Scott Guthrie posted some fantastic info on ASP.NET Extensions 3.5 to match up with Visual Studio 2008 and .NET Framework 3.5.

http://weblogs.asp.net/scottgu/archive/2007/11/29/net-web-product-roadmap-asp-net-silverlight-iis7.aspx

Highlights:

  • Silverlight 1.1 is now Silverlight 2.0
  • Silverlight 2.0 will start to get some of the great features that WPF has
  • Some of the ASP.NET AJAX Futures (like the browser history control) will be moved into ASP.NET AJAX
  • IIS 7 will ship early next year
  • There will be new ways to deploy to IIS 7 and do things like versioning and rolling back on single servers and web farms

Great stuff…check it out!

ASP.NET FindControl Recursive with Generics

While working on the new version of Channel 9, part of my job this time around was to "templatize" our entire community platform.  The way everything is set up now, aspx files are read in through the Virtual Path Provider (VPP), additional settings in the Page directive are set based off of database settings and the page is rendered.  All our controls are now ascx files with the CodeFileBaseClass set to a class that implements all the code.  This allows us to easily setup new controls and templates for our different sites if new ones are needed.  Right now, Channel 9 and Channel 10 are the only two sites that will be running this code.  In the halfway near future, VisitMIX and a yet to be named Student focused site will run this code as well, so templating was very important.  My other job for this sprint was to add ASP.NET AJAX functionality to the site.  As we get closer to launching the beta you'll see more posts from me sampling some of our code and techniques especially around ASP.NET AJAX.

The new EntryList control that I created takes a List<Entry>.  The control has a setting to let us set which ascx file we want to use to represent each Entry in the list.  These are loaded using Page.LoadControl.  The same thing goes for the Pager and Filters control in the header and footer of the EntryList.  All of these controls implement different interfaces so we can throw in different ones and look them up generically.  I don't necessarily know the names of these controls and needed a way to look them up by the interfaces they implement.  So I thought, "hey, I'll bet generics could help me out here."  I got the below code written, but unfortunately couldn't figure out how to properly cast the control by the type passed in.  My next door neighbor, our resident Sampy, helped me figure out that I needed to force the type coming in to be a reference (hence the "where T : class" part).  Here's the resulting code…

public static T FindControl<T>(System.Web.UI.ControlCollection Controls) where T : class
{
     T found =
default(T);

     if (Controls != null && Controls.Count > 0)
     {
         
for (int i = 0; i < Controls.Count; i++)
          {
              
if (Controls[i] is T)
               {
                    found = Controls[i]
as T;
                   
break;
               }
              
else
                   
found = FindControl<T>(Controls[i].Controls);
          }
     }

     return found;
}

Unlike a recursive method that's not generic, you would have to pass in the type as a parameter to the method, which would get passed down through every method call, and you'd have to cast the found control on every call you made to FindControl.  That wouldn't be a huge deal, but there is something nice about simplicity.  🙂

IMyInterface myControl = FindControl<IMyInterface>(this.Controls);

Note: This only returns the first instance of a control.  You could easily pass in a references List<IMyInterface> and add to it as you find them. 

This isn't break through code or anything, but it's fun for us, the dev geeks.  Expect to see more posts soon about coding techniques in our platform.

XNA Game Studio 1.0 Released

I've been playing around with XNA a little bit in my free time.  It's pretty darn easy to build a simple game with.  You can debug it from your Windows machine while running on your Xbox 360, all good stuff!

http://learnxna.com/archive/2006/12/11/Its-official.aspx

Be sure to check out the XNA content on Channel 9 too.

P.S. Don't mind the typo on Learn XNA.  "not" should be "now".  😉

Windows Forms to Windows Service Process to Process Communication Using WCF

I've been working on a side project for an application that will run on Windows Vista.  It involves a Windows Service that does P2P and WCF Endpoint code to do some communication.  I wanted to setup a WinForms app that could talk to it.  I could just set up another http endpoint, but that would be slower and open up my security surface area.  Instead I wanted my application to talk to the Windows Service in memory.  The way to do this is through named pipes in WCF.  It was fairly easy to figure out how to do, but currently WCF is a bit picky on the details so it took a while to get it going.  I thought I'd share how to setup this up with some sample code.  Note: I didn't use WPF for the UI because I don't know it well enough yet and know Windowns Forms pretty well.  I imagine a WPF app would connect about the same.

Setting up the WCF Service and Contract

Setting up the Named Pipe

Setting up the Metadata Service

Connecting to the Service

 Enjoy!