Expression Blend in Action MEAP begun

March 11, 2011 1 comment

Hi folks!  Last week while I was attending the MVP Summit, the MEAP for my upcoming Manning Publication title “Expression Blend in Action” was launched.  If you aren’t familiar with MEAP, it is a great program that Manning does where you can purchase the book and receive the chapters as they are written.  You can then provide feedback and participate in the book forum: YOU can influence the content and quality of the book!  Plus you don’t have to wait for the whole thing to be printed – it’s a win win all around.

As a special offer, between now and April 1st, you can get 50% OFF by using the following discount code: exblend50.  Feel free to spread this around, but remember it’s only good in March, so don’t miss it!

I’m obviously doing a lot of writing for the book, so my blog is suffering, but I will keep you posted here regarding updates.  If you’ve already bought it I sincerely thank you for all your support!  If you haven’t picked it up yet, what are you waiting for? :-)

Categories: .NET

Vote for my presentations at MIX!

January 25, 2011 3 comments

Hi friends!

Two of my sessions made the Open Call to present at MIX in April.  MIX presenters are primarily Microsofties but they include 10 presentations from community folks like me.  These are selected by public vote: the top 10 vote getters will have the chance to present at MIX.  This is my dream event so I’m hoping I can get enough votes to go, and that’s where you come in!

Would you please consider voting for my presentations?  It only takes a moment and I would really appreciate it.  Voting pages for the two sessions are here: – Expression Blend and the Visual State Manager: A Deep Dive – Container Driven Design with Blend

Thank you so much for your help and I hope to see you at MIX!

Categories: .NET

Announcing BlendSIG

December 10, 2010 Comments off

About BlendSIG

I am happy today to officially announce and launch BlendSIG,  a Virtual Blend Special Interest Group.  Inspired by LiDNUG (the LinkedIn .NET User Group) BlendSIG meetings are held online during working hours using LiveMeeting.  We hope that this will allow people from all over the world to join in and learn more about Blend. 

We will host monthly meetings on the 2nd Wednesday of each month at 2pm EST.  These meetings will be LiveMeeting screen casts.  Guests and presenters will be Blend professionals, such as members of the Microsoft Blend team, Blend MVPs, authors, and other knowledgeable parties.

Join the BlendSIG Group at Members of this group will receive notifications of events and interact with each other through the mailing list.  We also would like to encourage members to suggest topics and speakers.  Please join today!

You can also follow BlendSIG on Twitter: @blendsig.

The Inaugural Meeting

Our first meeting will be January 12, 2011, and I am happy to announce that Dante Gagne, Blend PM, will be our inaugural speaker.  Dante will be presenting on Behaviors and I’m really looking forward to it!

Registration for the January meeting is now live and available at

Please share this information with your user groups, companies, and interested parties.  I think together we could make this a rousing success!

Categories: .NET

SQL Saturday 61 Coming to DC

November 23, 2010 1 comment

If you are a regular reader then you know I spent some time this year learning SQL Server Integration Services (SSIS).  I’ve used it in several projects and have been very happy with the results, even if I have made a few mistakes along the way.  In fact, I was so enamored of what I was able to do in such a short time that I submitted to present not one, but two sessions at the upcoming SQL Saturday DC (#61), and to my surprise they were both selected!

Below is some information about the sessions, I hope to see you there!

SSIS for real: a walk through a real world project

Abstract: In this presentation I will walk though a complete real-world SSIS project that pulls data from an AS/400 and converts it to a SQL Server destination. In addition to specific AS/400 conversion issues I will also cover topics like dynamic OLEDB connections, and creating an effective work flow. Along the way we’ll take a look at how I use Derived Columns, Conditional Split, Lookup, and Script components to solve every day conversion issues.

The specific problem domain that SSIS solved for me was converting data from the EBCDIC world of the AS/400 (iSeries, System i, name-du-jour) to SQL Server.  Previously this had all been done with straight ADO.NET applications and performance was horrendous, to put it nicely.  Now with SSIS we have a solution that implements the Incremental Load pattern that is extremely performant. I’ll be discussing this project from start to finish.

Intro to C# for the SSIS Script Component

Abstract: The Script Component is an extremely powerful element in SSIS because it brings in the full capability of the .NET Framework. With first-class development tools and languages like C# you can solve problems that previously required very complex SQL or Expressions. If you’d like to learn enough C# to more effectively use the Script Component for Transformations, then this session is for you.

As a C# developer I was very happy to learn about the Script Component in SSIS 2008.  When I had to port my Package back to 2005 I discovered that it only supported Visual Basic.  I was able to make do, but it led me to the conclusion that there are probably plenty of SSIS folks who would like to know more about C#.  The session will include some C# basics and focus on things that you would find useful for data transformation, like string manipulation, data conversion, Regular expression matching, and more.

Categories: .NET

Simple, Blendable, DI driven ViewModels

November 19, 2010 3 comments

I hope you won’t think less of me, but I need to admit something: Dependency Injection still confuses the heck out of me.  The first time I met my good friend Kevin Hazzard he was talking about Castle Windsor with someone at an after party for a Microsoft event in Washington, D.C.  I was new to the community scene and had never met Kevin or most of the people in the room.  Wanting to fit in with the crowd I made the mistake of asking “what’s Castle Windsor?” which soon led to me asking “What’s Dependency Injection?” which even sooner led to my eyes glazing over and my brain retreating to its happy place.  I spent the next hour bobbing my head up and down, pretending to keep up with the conversation, but truthfully I was completely lost.

In the years since I’ve tried to learn DI: I’ve read articles, downloaded samples, gone to presentations, and had conversations until I was blue in the face.  I’ve made progress but I am still not totally comfortable with the whole idea.  Don’t get me wrong: I believe there is value there, and I have used it successfully in a couple of projects, but there is no guarantee I’ve done it properly.  It still feels like Black Magic but I figure if I keep plugging away it will eventually sink in.

On a side note, isn’t “Dependency Injection” a terrible name?  Almost as bad as “Inversion of Control”.  Neither one of these really describes what’s happening.  It sounds like what we are doing is injecting dependencies, meaning actually inserting dependencies, which would create more dependencies!  Really, we are resolving dependencies, or injecting dependent objects, but I guess Dependent Object Resolution is a little long winded.

The ViewModelLocator Pattern

I watched the video of John Papa’s PDC10 presentation Kung Fu Silverlight: Architectural Patterns and Practices with MVVM and RIA Services with great interest.  I’m working primarily in Silverlight now, using RIA Services and of course MVVM.  I downloaded the source code and have been working through it primarily focused on the ViewModelLocator pattern.

I’ve been aware of the pattern for a while but never understood how it worked before, so I wanted to give it a try.  The approach certainly works but it felt heavy and confusing, I’m sure that would pass as I grow more familiar with the pattern. Then again, it could just be me, but it seems there are lots of moving parts and misdirection.  Let me see if I can map it out for you as I understand it:

- ServiceProviderBase: this is an abstract class that holds a static instance of the active ServiceProvider.

- A ServiceProvider is a class that inherits from ServiceProviderBase that has a reference to a Data Service instance (the class that manages all the data interactions via RIA services).  For this exercise there are two Service Providers, one for Design time and one for Run time.  It’s a little confusing, but the run time class is simply named ServiceProvider.  The design time class is called DesignServiceProvider.

Let me stop here for a second: ServiceProviderBase is inherited by the two Service Provider classes, and it’s primary function is to decide which class to instantiate and return from a static method, which upcasts the results to itself:

public abstract class ServiceProviderBase
    public virtual IPageConductor PageConductor { get; protected set; }
    public virtual IBookDataService BookDataService { get; protected set; }

    private static ServiceProviderBase _instance;
    public static ServiceProviderBase Instance
        get { return _instance ?? CreateInstance(); }

    static ServiceProviderBase CreateInstance()
        // TODO:  Uncomment
        return _instance = DesignerProperties.IsInDesignTool ?
            (ServiceProviderBase)new DesignServiceProvider() : new ServiceProvider();

        // TODO:  Comment
        // return _instance = new ServiceProvider();

This strikes me as convoluted, but let’s move on.

- The ViewModelLocator, the namesake of the pattern, is a class that holds a set of ViewModel properties.  These ViewModels require (or have a dependency on) the Data Services that are stored in the ServiceProvider instance returned from ServiceProviderBase.  When a ViewModel is requested from the ViewModelLocator, it uses ServiceProviderBase to retrieve the current Data Service and uses it in the constructor to create the ViewModel.  This is a form of Dependency Injection called Constructor Injection and is the most popular by far since many people use it without realizing they are using DI!

Here is the code from the sample:

public class ViewModelLocator
    private readonly ServiceProviderBase _sp;

    public ViewModelLocator()
        _sp = ServiceProviderBase.Instance;

        // 1 VM for all places that use it. Just an option
        Book = new BookViewModel(_sp.PageConductor, _sp.BookDataService);

    public BookViewModel Book { get; set; }
    //get { return new BookViewModel(_sp.PageConductor, _sp.BookDataService); }

    // 1 new instance per View
    public CheckoutViewModel Checkout
        get { return new CheckoutViewModel(_sp.PageConductor, _sp.BookDataService); }

This is more understandable, like a central repository of ViewModels for the entire application.  This approach assumes that they all use the same Data Service, but I’m totally cool with that because it is extremely likely.  What’s nice here is that the ViewModel is always the same regardless of which Service Provider is currently active.  The bad news is that it breaks some aspects of Blendability because there is no empty constructor, but more on that later.

- Now we need to access the ViewModelLocator, so create a ResourceDictionary that contains an instance declaration of the locator and add a reference to the dictionary in the App.xaml MergedDictionaries section.

<local:ViewModelLocator x:Key="Locator" />
<ResourceDictionary Source="Assets/ObjectResourceDictionary.xaml"/>

- Finally, bind the UserControl’s DatContext to the correct ViewModel property in the ViewModelLocator.

DataContext="{Binding Book, Source={StaticResource Locator}}"

If you are confused after reading the above, don’t worry because you are not alone.  I struggled for some time to sort this out and I’m not entirely convinced I ever totally got it right.


What I came up with

I know it’s easy to play desk chair quarterback, so before I begin let me say that it took people a heck of a lot smarter than me to come up with this and it works, so if you are already successfully doing this I’m not telling you to switch. 

Trying to grok what was going on, I just kept staring at it and thinking there should be a cleaner way, so I played with it until I came up with what I’ll share in the next section.  It’s quite possible that my approach has serious problems, so please feel free to leave comments below.

I basically set out to do two things: first, I prefer to see the DataSource listed in the Data tab in Blend.  Using the above approach you have to add the reference to the ViewModelLocator StaticResource defined in the ObjectResourceDictionary manually. The idea is that the ViewModelLocator acts as a Singleton, because there is only one instance created for the entire application.  Unless you NEED to enforce a Singleton, then this is not necessary in my mind. 

Because it is a Static Resource, the bound DataContext object will not show up as a Data Source in the Data tab. It will, however, show the appropriate properties in the DataContext panel on the bottom of the Data tab, which may be sufficient for you.

If you want to use the Data tab in Blend, however, you can remove the UserControl DataContext reference and create a local instance of the ViewModelLocator object using the standard Create Object Data Source tool in Blend.  Then you can drag the appropriate ViewModel property and drop it on the LayoutRoot to bind it to the DataContext.

The result of the second approach is that I can see ALL the ViewModel objects, which I may or may not want.  It also requires an extra level of nesting to get to the desired ViewModel object.  To get back to the more traditional Blend approach, we need to be able to bind directly to a local instance of the ViewModel itself.  Of course, doing so breaks the ViewModelLocator pattern, but I’m no purist. :-)


The Non-locator Locator Pattern

My solution does away with the ServiceProviderBase and ViewModelLocator classes.  My reasoning is pretty straight forward: all I really need to be able to do is change what Data Service class my ViewModel uses based on certain scenarios.  I want a dummy service for design time but the real deal to execute at run time.  And I may want to create a special service for testing scenarios.  Getting back to how I started this post, this sounds like a job for Dependency Injection!

Since I’m writing a Silverlight application I need to make sure the IoC container I choose supports it.  I’ve been using StructureMap but it doesn’t support Silverlight yet (rumor has it V3 will add Silverlight support). Unity 2.0 for Silverlight does however, so I’m using this project as an excuse to try it out.  It shouldn’t matter what framework you use.

I added the following code to the Application_Startup method in App.xaml.cs:

var iocContainer = new UnityContainer();
if (DesignerProperties.IsInDesignTool)
    iocContainer.RegisterType<IClientService, ClientServiceMockData>();
    iocContainer.RegisterType<IClientService, ClientService>();
Resources.Add("IocContainer", iocContainer);

This creates a UnityContainer and registers the appropriate Data Service.  I then add the container as an Application level resource, so I can retrieve it from anywhere in the application.  This uses the same DesignerProperties. IsInDesignTool approach that the previous ViewModelLocator used.  Now we head to the ViewModel itself.

The ViewModel

In the ViewModel I add a property for IClientService with a backing field.  In the get block, if the backing field is null, I access the IocContainer application resource and use that to extract the IClientService

private IClientService _clientService;
protected IClientService ClientService
        if (_clientService == null)
            var ioc = Application.Current.Resources["IocContainer"] as UnityContainer;
            _clientService = ioc == null
                ? new ClientServiceMockData()
                : ioc.Resolve<IClientService>();
        return _clientService;
    set { _clientService = value; }

NOTE: I do want to share a problem I had here: ideally, ioc.Resolve<IClientService>() should work for both Design and Run time.  This solution works as desired at run time, but at design time the IocContainer resource is null.  To solve this and get run time data I hardcoded the creation of ClientServiceMockData class if the resource is null.  This of course adds a dependency on the ClientServiceMockData class, so if you have any suggestions on how to solve this problem I would appreciate hearing them.

This approach is probably wrong somehow, but I’m accessing the IoC container from inside the object that has the dependency.  I suppose this adds a dependency on the container class itself.  I did it this way to complete the Blendability.  In order for Blend to recognize the ViewModel as an Object Data Source at run time it has to have an empty constructor, so the ViewModel now has two constructors:

public ClientViewModel()

public ClientViewModel(IClientService clientService)
    ClientService = clientService;

You can see that the second constructor still allows Constructor Injection, so if you wanted to use special data for testing all you would have to do is pass in a specific Data Service to the constructor.

At this point we now have a completely Blendable ViewModel that supports design time data in far fewer objects and steps, and as an added bonus it can increase your geek factor because it uses Dependency Injection!



It seems to me that this is a much simpler way to achieve the same result, but I’m sure the Patterns and Practices folks will be able to spot the holes in it.  I’d really like to learn this stuff better so please feel free to leave your comments below.  What is wrong about this idea?  What is good?  Is there an even simpler way to achieve it?  Let’s hash it out: enquiring minds want to know. 

SSIS and DelayValidation

October 14, 2010 6 comments

If you’re a regular reader then you’ll know I’ve recently become enamored of SSIS.  I’m absolutely blown away by this product, I wish I learned about it 5 years ago!

Of course, being new to such an extensive technology means dealing with landmines along the way.  Unfortunately, I’ve run into a couple of them already.  The first one was my own fault: I developed a project in 2008 but the client has Sql Server 2005.  To solve it I had to install Sql Server 2005 and create a 2005 version of the Package.

AcquireConnection Method Error

The second issue I’ve encountered was hardly as intuitive.  I was at the client site yesterday deploying my first SSIS Package outside my own network.  With the help of Andy Leonard, my SSIS mentor, I had worked through all the necessary steps to make the Package dynamic, a process worthy of a blog post of its own.  At the client site I followed my cheat sheet to the letter, explaining every step to the client along the way.  After solving a missing prerequisite problem on the server, we fired up the Package only to be quickly stopped with a Validation failure message:

The AcquireConnection method call to the connection manager failed with error code 0xC0202009.

I assumed there was a problem with the dynamic connection strings. I spent about an hour diagnosing the problem only to find out there was no problem, at least not with the dynamic connections.  The problem, it turns out, was in a thing called DelayValidation.

Dynamic vs. Design Time Connection Strings

When you design an SSIS Package, you need to define connections to data sources and destinations that you can access at design time. Without these connections, SSIS would be pretty useless. So these design time data connections have to be hard coded somewhere: I put mine in package variables and bind the ConnectionString property of the ConnectionManager objects to the variables.  These variables are then overridden at runtime by external values, making the connections dynamic and portable.

What I was unaware of was that each ConnectionManager object and each DataFlow Task has a property called DelayValidation.  When the Package begins, it validates all of the DataFlow tasks prior to executing any of them.  If DelayValidation is set to False, then the validation process uses the design time connection objects.  In other words, it tries to connect using that connection string before it has a chance to be set by the dynamic process.  And here’s the kicker: False is the default value, so this is the default behavior.


Working on my own network, I never even noticed this was happening.  On the client network, however, it immediately blows up because the tasks cannot connect to my design time databases.  I found a good article online that explained the problem and it actually makes sense.  The solution is to set DelayValidation to True, which will delay the validation process until the task begins to execute, giving it time to be set dynamically.

I started by setting the property on every ConnectionManager object. At first I believed that this would be sufficient but it didn’t stop the validation error: I had to do the same thing to every DataFlow task as well, after which the Package ran properly.  This was a real pain because I had so many to change. I could select multiple tasks within the same container, but I could not select tasks across container boundaries, and I have a lot of containers.

While I understand what DelayValidation is doing and why it does it, I don’t understand why False is the default value.  If nothing else, it seems to me this should be a Package level setting.  If you know of a better or easier way to handle this problem, please share it in the comments below.

Categories: Database, SQL Server, SSIS

Richmond Code Camp X

October 11, 2010 2 comments

This past weekend, about 200 geeks, developers, and other techies converged on the Parham Road campus of J. Sargeant Reynolds Community College in Richmond, VA for Richmond Code Camp X.  I think it’s great when an event has been around long enough to begin using Roman Numerals. 

Planning and Organization

Regular readers already know I am a huge fan of Code Camps and #RichCC is as good as they come.  Of course, you could claim that I am a little biased: I’ve been on the planning committee for the event for the last two installments.  But believe me, this was a great event long before I got here!

In fact, one of the things I wanted to address today was how the Richmond Planning Committee is a great model for others to adopt.  Andy Leonard wrote about some of this on his blog:

There’s a lot that goes into planning an event of this magnitude. I commend the Code Camp Leadership Team for their hard work, but the team possesses a quality that will ensure many more Richmond Code Camps to come: absence of ego.

There’s no penalty for stepping up or down on our team. Life happens, people move, get more and less busy, change jobs, and just have other plans. Why punish people for that? Especially in a volunteer organization? The on-point person doesn’t try to "edge out" previous leaders. That’s because we’re all pretty secure individuals. It’s a great group to be part of, and I love every member of our team.

I think he really hit the nail on the head when he used the phrase “absence of ego.”  In the spring, Kevin Griffin and I were invited to join the committee for RCC2010.1.  This was/is a serious group of community activists: Kevin Hazzard, Justin Etheredge, Darrell Norton, Robin Edwards, Susan Lennon, Frank La Vigne, Andy Leonard, Kevin Israel, and please forgive me if I left anyone out. 

Each of these folks is a super star in their own right, so it would shock no one to find politics, backstabbing, prima donnas, or any of those other things that happens with a group this size of seriously accomplished folks.  The truth, however, is more shocking: there isn’t a territorial attitude in the bunch.  Kevin and I were immediately welcomed and assigned tasks that obviously others had done before we came along.

The best thing of all: no one “owns” anything.  If you need to jump tasks to make sure something happens, do it.  If you need to ask for help you get it.  And best of all, if you can’t do something, someone else will.  When something goes wrong or contrary to plan, there is always someone there to fill in the gap and address the problem.  Since everyone is empowered, this committee is the epitome of the “high functioning team”: it is truly Agile. 

In short, this committee ROCKS, and the result is an event that consistently raises the bar.  I just wanted to share some of that and say “Thanks” for letting me be a part.

Community Megaphone Podcast

I’ve had the opportunity to be involved with the Community Megaphone Podcast on more than one occasion since its inception: I was the 2nd guest and the 1st guest co-host.  I also got to sit in on the Speaker Horror Stories panel in CodeStock earlier this year.  I have an absolute blast every time I get to participate on this show.

One unfortunate thing about this weekend is that Philly Code Camp (another favorite) was scheduled the same day.  One of the show hosts, Dane Morgridge, lives in Philly and so he went there instead of coming to Richmond.  With Andrew Duthie, aka The Devhammer, going to Richmond, they decided to do live recordings at both events, another first for the podcast.  Of course, this meant Andrew was on his own, so I was really pleased to sit in again as guest co-host.

Frank LaVigne

We did two sessions with Frank La Vigne, one of the original founders of Richmond Code Camp.  During one of those sessions I came dangerously close to ensuring I’ll never be invited back: it turns out some people are a little sensitive when you make jokes about VB (who knew!?)  The good natured ribbing aside, we had a great time talking with Frank about the early days of RCC, his community work since moving to Northern Virginia, Windows Phone 7, and even his infant son Jake who made an appearance at the event and was the hit of the Speaker’s Dinner. 

Jim Pendarvis

We had a great chat with Jim Pendarvis, founder and organizer extraordinaire of Southern Maryland Give Camp.  The 2nd installment of SOMDGC is scheduled for March 25-27th and they have a new goal this year of 150 developers and 25 non-profits.  Jim talked about the National Day of Give Camp coming up on Martin Luther King day, saying the reason for moving SOMDGC back is the unpredictability of the weather.  I just think he doesn’t want to shave his head in a snow storm!

And speaking of last year’s show, this year we have TWO new items of interest.  First, if they meet their goal of 150 developers, not only will Andrew Duthie get a mohawk, he will get it dyed in a color of our choosing!  There is also talk of a henna tatoo…

Secondly, we have a challenge going now between Jim, Kevin Griffin, and myself.  To paraphrase the immortal words of Tommy Callihan from the movie Tommy Boy, the three of us have “what the doctors refer to as a little bit of a weight problem.”  So here is the deal: whichever one of us who loses the largest percentage of his body weight by Give Camp will be determined the victor.  The two losers will be required to dress up on the last day of Give Camp as a character from Harry Potter.  The characters will be chosen by the attendees, and I’m sure hilarity will ensue.

Van” Van Lowe

“Van” Van Lowe is a community organizer, blogger, and speaker from Northern Virginia.  He spoke with us about making the transi
tion from attendee, to speaker, to organizer within the community.  We also talked about attending Code Camps versus the larger national conferences like PDC and MIX.  And in a CMP Exclusive, he revealed his real name and told us the story of how he started going by “Van” as a result of his speaking activities.  Sorry – I’m not going to tell you the story here, you’ll just have to listen to the podcast yourself!

And don’t forget the others…

There were some other interviews as well that I wasn’t in on: Kevin Griffin took the co-host seat for a session and interviewed Rob Zelt, President of INETA.  And then later, new Azure MVP David Makogon filled in while I went to give my presentation and they interviewed up and coming community speaker Stuart Leitch from Charlottesville.  Stuart is a friend of mine and I can’t wait hear that session for myself!

A New Presentation

I did have the chance to unveil a new presentation during the last session of the day: Expression Blend and the Visual State Manager: A Deep Dive.  I’m never sure how a session is really going to go over until I give it for the first time. Recognizing that Blend is still unfortunately a niche topic, I’m also never sure how well attended a session will be, so I was pleasantly surprised to find a packed room: there were even a couple of people standing in the back for a little while!

This one was a lot of fun: I wanted to show some Blend coolness that I don’t typically get to cover in the introductory sessions.  We spent some time going over Templating basics and then used the VSM to solve some problems with Templates.  The second half of the presentation was all about creating Custom Visual States and how to use them in creative ways.  We covered Transitions, Effects, and Multiple Custom States, and it was very well received.  My thanks to everyone who sat in and for all the nice comments afterwards.

A Brief Respite

Without question we can add Richmond Code Camp X to the history books as an extremely successful event.  We’ll take a very brief hiatus, but before long we’ll start the process all over again for Richmond Code Camp XI.  You can go ahead and put it in your calendar now for May 21st, 2011, I hope to see you there!

Categories: Community

Get every new post delivered to your Inbox.