Monday, July 13, 2009

Demo Showcase Suite Launch

This blog has been a little devoid of content for the last few months.  It’s not because I had nothing to say, it was because everything I had to say, couldn’t be said.  The three letters a blogger hates to hear are ‘N D A’, non-disclosure agreement.  There are still a few things I can’t talk about, but by and large, the ban has been lifted.

This morning, at 9:00 AM Central Time, Allison Watson, Corporate VP of the Microsoft World Wide Partner Group, announced the release of Demo Showcase Suite.  

“Microsoft’s® Demo Showcase Suite is a collection of demonstration resources that includes the new Demo Showcase application for creating your own click-through demos as well as this community site to manage your demos, search for demos, distribute demos you’ve created and stitch different demos together to make your own. Sign in with Windows Live ID and take a look through this site and download the Demo Showcase application to get started creating your own demos that you can share through Silverlight or download as standalone executables”

For the last 9 months, I have been immersed in this project as the lead architect.  It’s the biggest project I’ve ever led, and a high water mark in my career.  With a small team of developers and QA’s, we turned out a product that we are all quite proud of. 

You can see what the app does by going out and using it.  I’m going to focus my next few blog posts on the architecture of the product, the history of the project, and lessons and technology we learned while doing it.  For those of you that can’t wait, here’s a brief sample of the technologies we used (in no particular order):

  • Windows Azure
  • Windows Live ID Authentication
  • Unity Framework + Enterprise Application Blocks
  • Entity Framework
  • LinqToSql
  • WPF
  • MVVM in WPF
  • Silverlight 2
  • ASP.NET
  • Test Driven Development
  • Microsoft Geneva Framework
  • ACS
  • SQL Server 2008
  • Custom ASP.NET Handlers
  • Object Graphs in EF using QuickGraph.NET
  • ASP.NET Dynamic Data
  • WCF
  • REST
  • RSS Feeds
  • Custom WPF Compilation Engine
  • Log4Net
  • ASP.NET AJAX
  • Resharper 4.5

As you can imagine, things are still kind of hectic around here today.  I’ll try to update the blog this week with more details.  For now, go give the app a try.  If you can’t get to it because you are not a partner, please contact Microsoft Partner Group, and get enrolled today!

Thursday, July 9, 2009

Allow MSI Downloads on ASP.NET Web Site

I can't tell you how many hours I spent over the last few weeks trying to debug a problem with a web site where we were trying to allow users to download an MSI from a blob. Sometimes it would work the first time, and then the next time, the site would try to download the .aspx file the code was running in.

What made it really confusing was that this problem only happened when we were running in Azure with IE 8. In IIS 7 running on Win2K8, it was fine. With Azure and FireFox, it was fine. At one point, we had it working on everything except IE 8 running on Windows 7 with a backend of Azure.

What I finally had to do, was to create an ASP.NET Generic Handler (ashx) that did the heavy lifting for me.  To give credit where credit is due, the suggestion came from someone I met while at the latest NerdDinner in Bellevue, WA on July 7.  (I wish I could give you his name, but I do know he was on the ADO.NET Services Team at Microsoft)   This is the second time that I have attended one of those dinners, and the second time I was able to solve a problem the next day based on advice given to me by someone there.   Many thanks to Scott Hanselman for getting these events put together.

Here was the final code:

public class MsiDownload : IHttpHandler



{



    protected readonly ILog _log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);



 



    public void ProcessRequest(HttpContext context)



    {



        string msiName = ConfigurationManager.AppSettings.Get("MSIName");



        byte[] returnedBytes = null;



 



        var blobManager = UnityFactory.Current.Resolve<IBlobManager>();



 



        try



        {



            returnedBytes = blobManager.GetMsi(msiName);



            if (returnedBytes == null)



            {



                _log.ErrorFormat("Error obtaining MSI from blob storage service. Returned bytes is zero length.");



            }



        }



        catch (Exception exc)



        {



            _log.ErrorFormat("Error obtaining MSI from blob storage service. Exception type: {0}, Exception Message {1}.", exc.GetType().ToString(), exc.Message);



        }



 



        if (returnedBytes != null)



        {



 



            context.Response.Buffer = true;



            



            // force download



            context.Response.ContentType = "application/x-msi;";



            context.Response.AppendHeader("X-Content-Type-Options", "nosniff");



            context.Response.AppendHeader("content-disposition", "attachment; filename=" + msiName);



            context.Response.AppendHeader("Content-Length", returnedBytes.Count().ToString());



            context.Response.OutputStream.Write(returnedBytes, 0, returnedBytes.Count());



            context.Response.Flush();



            context.Response.End();



        }        



    }



 



    public bool IsReusable



    {



        get



        {



            return false;



        }



    }



}


Thursday, February 19, 2009

Rhino Mock Error - rhino mocks requires a return value or an exception to throw

Sometimes it's just a matter of googling the right thing. I was trying to show someone how easy it was to develop mocks to help test, and wouldn't you know it, I kept getting errors in my test harness that I couldn't figure out. I thought it was because we were testing an object with a read only property and using the AutoMockingUnityContainer, but when I was finally smart enough to google the real exception being thrown:

rhino mocks requires a return value or an exception to throw


It immediately led me to this wonderful solution.

http://codemonkey.nmonta.com/2008/09/19/previous-method-requires-a-return-value-or-an-exception-to-throw/

Google FTW.

Book Review: Architecting Applications for the Enterprise

This morning I finished reading Dino Esposito's and Andrea Saltarello's book Microsoft .NET: Architecting Applications for the Enterprise. The highest praise for a technical book is that it immediately affected not just the work I was doing, but the way I work. This one did just that.

I've been writing code since I was 8 years old on my school's Commodore PET. That's was almost 30 years ago now. I've been doing it as a career since 1994. I started designing applications (as opposed to just being a code monkey), in 1997. I became what my company calls an Architect last year.

But I didn't start to think like an architect until just recently, and this book, which I power read over the course of 6 days, has had a profound impact on how I see my role within the company, and how I need to work to make myself, and my team more efficient. I've been bringing in tools and processes the last year or so to fix the low hanging fruit, but I still considered myself a developer first, and considered the architect role to be something I did between writing classes and specs.

The first half of this book is about the process. And though the first chapter is a little, um, dry (probably a few too many references to ISO and IEEE), it does help to build the profile for where an architect fits into an organization (big and small). These guys have been there, and done systems development where there is a client involved in the process. They aren't people who have been at some big software company and don't know what is involved in developing line of business software with a client who has no idea what it is they want when the project starts.

The second half of the book talks about application layers: The Business Layer, The Data Access Layer, The Service Layer and The Presentation Layer. I've worked in all these layers at one time or another, but it's only quite recently that I have truly begun to understand the Separation of Concerns rules, and things like dependency injection. This book not only helped top clarify these things in my mind so I can better understand all the other reading that I do that assumes that I know what SoC mean, but it also talked about misconceptions about the layers. I found the section on the service layer particularly appropriate because for a long time, I completely misunderstood Service Oriented Architecture. They cleared this concept up for me in a way no other publication ever has. I wish I had read that 4 years ago. I once built a 'Service Oriented Architecture' application with 80+ web services! What was I thinking?

My favorite part of the book was the 10 Final thoughts, their mantra as they call it. These were spot on, and proved to me that they had been there, and done that, when it came to developing real world applications. It gave them 'geek cred'.

The target audience for this book is probably senior devs and architects. It's probably too high up for low level devs to be interested in (though they should be). I highly recommend it for anyone who is moving up out of the weeds, and anyone who wants a high level picture of some of the most common design patterns in .NET.

The next book I'll be cracking open (tonight on the train ride home), is Julia Lerman's "Programming Entity Framework". 800 pages of data access goodness. Oh My!

Wednesday, February 18, 2009

MS-Test - Not Executed Error

I've finally found out what the issue was with my MS-Test harness, and why I am the only one currently seeing this issue in my office.

First I needed to turn on logging for MS-Test. Here's a link on how to do that.
http://blogs.msdn.com/yutong/archive/2006/10/03/How-to-Enable-VSTS-Logging_3F00_.aspx

Then, once I ran my tests, and looked in the log, I saw the following error message:

The Visual Studio performance and coverage logging engine is already running on the computer. Therefore, the test run cannot continue. Close the pending performance or code coverage session and then rerun the tests.

Here's a link to the fix
http://platinumdogs.wordpress.com/2007/12/

I'm the only one in the office having this problem, because I am the only one with VS2008 Team System Team Suite and running code coverage and analysis.

I also suspect that I'm the only one who's pounding out all the test code they need to be writing right now, but that's going to change. Soon.