<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/" version="2.0">
    <channel>
        <title>Bender's Blog</title>
        <link>http://jamescbender.com/bendersblog/Default.aspx</link>
        <description>... because jamesbender.com was already taken.</description>
        <language>en-US</language>
        <copyright>James Bender</copyright>
        <managingEditor>james.c.bender@live.com</managingEditor>
        <generator>Subtext Version 1.9.5.177</generator>
        <image>
            <title>Bender's Blog</title>
            <url>http://jamescbender.com/bendersblog/images/RSS2Image.gif</url>
            <link>http://jamescbender.com/bendersblog/Default.aspx</link>
            <width>77</width>
            <height>60</height>
        </image>
        <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/BendersBlog" type="application/rss+xml" /><item>
            <title>Just a reminder...</title>
            <category>Architecture</category>
            <category>ColARC</category>
            <link>http://jamescbender.com/bendersblog/archive/2008/10/10/just-a-reminder.aspx</link>
            <description>&lt;p&gt;... the the second meeting of the Columbus Architects Group (ColARC) will be Wednesday October 15th at the Quick Solutions office at 440 Polaris Pkwy Suite 500 in Westerville.&lt;/p&gt;  &lt;p&gt;This months topic is "The Architect as a Leader." More information can be found at &lt;a href="http://www.colarc.org"&gt;www.colarc.org&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;In other news, ColARC also has it's own Twitter feed! You can start following ColARC at &lt;a title="http://twitter.com/ColARC" href="http://twitter.com/ColARC"&gt;http://twitter.com/ColARC&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;See you all there!&lt;/p&gt;&lt;img src="http://jamescbender.com/bendersblog/aggbug/25.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Bender</dc:creator>
            <guid>http://jamescbender.com/bendersblog/archive/2008/10/10/just-a-reminder.aspx</guid>
            <pubDate>Sat, 11 Oct 2008 01:50:05 GMT</pubDate>
            <wfw:comment>http://jamescbender.com/bendersblog/comments/25.aspx</wfw:comment>
            <comments>http://jamescbender.com/bendersblog/archive/2008/10/10/just-a-reminder.aspx#feedback</comments>
            <wfw:commentRss>http://jamescbender.com/bendersblog/comments/commentRss/25.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Architects of the World Unite!</title>
            <category>Architecture</category>
            <category>ColARC</category>
            <link>http://jamescbender.com/bendersblog/archive/2008/08/18/architects-of-the-world-unite.aspx</link>
            <description>&lt;p&gt;Howdy!&lt;/p&gt;  &lt;p&gt;Long time no post.&lt;/p&gt;  &lt;p&gt;But I've been busy.&lt;/p&gt;  &lt;p&gt;And not just with XBox, drinking beer and napping. Although to be fair, there has been some of that...&lt;/p&gt;  &lt;p&gt;What I've been working on is the creation of the Columbus Architects Group. &lt;/p&gt;  &lt;p&gt;ColARC is a community user group for Architects and aspiring Architects to get together and share knowledge, experience and opinions. We are not bound by platforms and any Architect (or aspiring Architect) who is passionate about their craft is invited to attend.&lt;/p&gt;  &lt;p&gt;The topic for the first meeting is "What is an Architect?" The format for most meetings will be a fish bowl meeting, but there may be panel discussions and speakers at some meetings.&lt;/p&gt;  &lt;p&gt;Our first meeting is Wednesday September 10th at Quick Solutions in Westerville. We start at 6:00.&lt;/p&gt;  &lt;p&gt;Normally, we will meet the second Tuesday of the month, but there was a conflict this first month so...&lt;/p&gt;  &lt;p&gt;And yes, I know COJUG meets the same night. We're working on...&lt;/p&gt;  &lt;p&gt;Check it out at &lt;a href="http://www.colarc.org"&gt;www.colarc.org&lt;/a&gt; and hope to see you all there!&lt;/p&gt;&lt;img src="http://jamescbender.com/bendersblog/aggbug/24.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Bender</dc:creator>
            <guid>http://jamescbender.com/bendersblog/archive/2008/08/18/architects-of-the-world-unite.aspx</guid>
            <pubDate>Mon, 18 Aug 2008 22:55:18 GMT</pubDate>
            <wfw:comment>http://jamescbender.com/bendersblog/comments/24.aspx</wfw:comment>
            <comments>http://jamescbender.com/bendersblog/archive/2008/08/18/architects-of-the-world-unite.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://jamescbender.com/bendersblog/comments/commentRss/24.aspx</wfw:commentRss>
        </item>
        <item>
            <title>The Big Non-Story</title>
            <link>http://jamescbender.com/bendersblog/archive/2008/07/12/the-big-non-story.aspx</link>
            <description>&lt;p&gt;For those of you who don't know, I do a lot of interviews. Not just for my current company. It seems that every company that I've worked for has decided at some point that I'm good at gauging a potential employee's technical chops as well as determining if their personality is a fit for the group. I've lost count of how many interviews I've done, but it has to easily be in the hundreds.&lt;/p&gt;  &lt;p&gt;Recently &lt;a href="http://stevenharman.net/blog/Default.aspx" target="_blank"&gt;Steve Harman&lt;/a&gt;, a co-worker of mine appeared on an episode of &lt;a href="http://deepfriedbytes.com/" target="_blank"&gt;Deep Fried Bytes&lt;/a&gt;. Steve recounted (third person) a story about an "incident" that occurred during an interview I conducted YEARS ago.&lt;/p&gt;  &lt;p&gt;Basically, halfway through the interview, the candidate started to cry.&lt;/p&gt;  &lt;p&gt;It started off as any normal phone interview; introduced myself, talked about his resume a little, than started settling into some technical questions to find his skill level. As the discussion started turning to more advanced topics, I noticed a distinct pause between when I asked the question and when I got the answer. I also noticed the sound of pages in a book being turned (this was in the days before Google). I asked him if he was looking up the information in a book. That's when he basically started to cry.&lt;/p&gt;  &lt;p&gt;He explained to me that he had been out of work for sometime, and was starting to get desperate. His mother was sick and he was worried about how he was going to take care of her. I felt very bad for the guy. At the end of the interview I thanked him for his time. I reported back to my employer that he was not a good candidate for the lead developer position we were looking to fill, but if something a little lower on the ladder came around we should talk to him again. &lt;/p&gt;  &lt;p&gt;I've actually only told this story to a VERY few people, but because it is one of the "great interview war stories" it seems to have developed some legs, not to mention a life of it's own! To this day I have people asking me about it who I KNOW I never told the story too. Not that it's a big secret, I'm just surprised how many people seem to think it is a great story. And maybe it is.&lt;/p&gt;  &lt;p&gt;But the reality was not great. Just to be clear, it is NOT (nor should it EVER BE) the goal of an interview to make someone uncomfortable enough to cry. Yes, I want to ask "hard" questions and have the person not only be able to prove their technical prowess, but I also want to find out a little bit about their character and personality. But the truth is that making a person cry during an interview is NOT something I'm proud of or something I ever want to experience again. Fact is, I was probably almost as uncomfortable as the potential candidate that I speak of, and I'm not at all eager to go through that again!&lt;/p&gt;  &lt;p&gt;Anyway, I just wanted to clear this up a little since many people seem to be getting the wrong idea about the event. Challenging interview == good. Candidate having a "breakdown" == bad.&lt;/p&gt;&lt;img src="http://jamescbender.com/bendersblog/aggbug/23.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Bender</dc:creator>
            <guid>http://jamescbender.com/bendersblog/archive/2008/07/12/the-big-non-story.aspx</guid>
            <pubDate>Sat, 12 Jul 2008 20:55:54 GMT</pubDate>
            <wfw:comment>http://jamescbender.com/bendersblog/comments/23.aspx</wfw:comment>
            <comments>http://jamescbender.com/bendersblog/archive/2008/07/12/the-big-non-story.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://jamescbender.com/bendersblog/comments/commentRss/23.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Happy Contribupendence Day!</title>
            <category>Contribupendence Day</category>
            <link>http://jamescbender.com/bendersblog/archive/2008/07/03/happy-contribupendence-day.aspx</link>
            <description>&lt;p&gt;Did you do your five recommendations? There is still time, so get to it!&lt;/p&gt;
&lt;p&gt;Here are my "first" five (in no particular order):&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://gayleforce.wordpress.com/"&gt;Gayle Craig&lt;/a&gt; - Gayle is an extremely smart and talented developer who is not afraid of facing new challenges head on. Her recent move from Java to Ruby demonstrates that she is always looking for ways to expand and increase her knowledge. Instead of speaking, Gayle chooses to interact with the development community in a more personal, one-on-one mentoring role which I feel often does not get her the recognition that she so richly deserves.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.panadmonial.com"&gt;Amanda Laucher&lt;/a&gt; - Amanda is one of the smartest people I have had the pleasure to know. Her ability to easily grasp and apply new, abstract and difficult concepts to mainstream development methodologies and techniques is nothing short of incredible. Her work in the .NET development community is highly appreciated and she can always be counted on to teach people something new and immediately useful.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.codinggeekette.com/"&gt;Sarah Dutkiewicz&lt;/a&gt; - Sarah is an extremely smart, talented and energetic member of the .NET community. She and her colleges in Cleveland recently organized the first Day of .NET in the region with tremendous results. Her dedication to the development community is second to none. Her passion for technology is exemplified by her eagerness to learn and apply new technologies and techniques.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.mcwherter.net"&gt;Jeff McWherter&lt;/a&gt; - Jeff has been instrumental in creating and nurturing a .NET development community in Eastern Michigan area that is an irreplaceable asset to its members. His commitment to the community was demonstrated by Jeff with the success of the Lansing Day of .NET which brought community members from as far away as Tennessee to participate and benefit from the knowledge and experience of his peers.  Jeff’s hard work and dedication to making this event so successful cannot be overstated. He is an asset to any team he is a part of.&lt;/p&gt;
&lt;p&gt;&lt;a target="_blank" href="http://www.jeffreyhunsaker.com/"&gt;Jeff Hunsaker&lt;/a&gt; - Jeff is an extremely smart, capable and talented member of the .NET community. Jeff is someone that enjoys tackling new challenges and helping others in the community overcome their own challenges. Jeff is very passionate about technology and is quick to learn new tools and techniques and find ways to leverage them in ways that make developments faster, less expensive and more successful.&lt;/p&gt;
&lt;p&gt;So, what do I mean by my "first" five? Well, as I made my list I would think of a name that would make me think of two more names, which would make me think of two more names and so on and so on...&lt;/p&gt;
&lt;p&gt;Currently my list is over 20 people. So, instead of trying to pare this down, I'm going to go ahead and write recommendations for ALL of them! It's going to take me probably most (all?) of the weekend, but now that I'm in the spirit of the "holiday" it seems the right thing to do.&lt;/p&gt;&lt;img src="http://jamescbender.com/bendersblog/aggbug/22.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Bender</dc:creator>
            <guid>http://jamescbender.com/bendersblog/archive/2008/07/03/happy-contribupendence-day.aspx</guid>
            <pubDate>Thu, 03 Jul 2008 22:06:24 GMT</pubDate>
            <wfw:comment>http://jamescbender.com/bendersblog/comments/22.aspx</wfw:comment>
            <comments>http://jamescbender.com/bendersblog/archive/2008/07/03/happy-contribupendence-day.aspx#feedback</comments>
            <wfw:commentRss>http://jamescbender.com/bendersblog/comments/commentRss/22.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Contribupendence Day?</title>
            <category>Contribupendence Day</category>
            <link>http://jamescbender.com/bendersblog/archive/2008/07/01/contribupendence-day.aspx</link>
            <description>&lt;p&gt;What is Contribupendence Day? I mean, besides a word that apparently is not in my spell checker dictionary?&lt;/p&gt;  &lt;p&gt;Well, according to &lt;a href="http://www.jeffblankenburg.com/index.html" target="_blank"&gt;Jeff Blankenburg&lt;/a&gt;, it's a day. Specifically July 3rd. More specifically, it's a day set aside for all of us in the development community to use those often overlooked features of social networking sites (like &lt;a href="http://www.plaxo.com/" target="_blank"&gt;Plaxo&lt;/a&gt; and &lt;a href="http://www.linkedin.com/" target="_blank"&gt;LinkedIn&lt;/a&gt;) and write something nice things about your peers. &lt;/p&gt;  &lt;p&gt;So, on July 3rd., pick a few people who's work in the community you've appreciated in the past and write a glowing review (or just a few nice words) about them.&lt;/p&gt;  &lt;p&gt;So, is this just another made-up holiday?&lt;/p&gt;  &lt;p&gt;No! Well, yes. Sort of. I mean, we don't get the day off or anything, BUT we also don't have to mail out cards or buy gifts for people or anything. I mean, you can have a cook-out or something. If you want. That would be kind of cool....&lt;/p&gt;  &lt;p&gt;Anyway, I've picked my five people. Have YOU?&lt;/p&gt;&lt;img src="http://jamescbender.com/bendersblog/aggbug/21.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Bender</dc:creator>
            <guid>http://jamescbender.com/bendersblog/archive/2008/07/01/contribupendence-day.aspx</guid>
            <pubDate>Tue, 01 Jul 2008 22:41:10 GMT</pubDate>
            <wfw:comment>http://jamescbender.com/bendersblog/comments/21.aspx</wfw:comment>
            <comments>http://jamescbender.com/bendersblog/archive/2008/07/01/contribupendence-day.aspx#feedback</comments>
            <wfw:commentRss>http://jamescbender.com/bendersblog/comments/commentRss/21.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Give Camp!</title>
            <category>Give Camp</category>
            <link>http://jamescbender.com/bendersblog/archive/2008/06/23/give-camp.aspx</link>
            <description>&lt;p&gt;What is a "Give Camp?" It's an event designed to allow developers, designers, DBAs, Architects and enthusiasts to donate their time and talent by helping to developer or update applications for charities. &lt;/p&gt;
&lt;p&gt;Many of these organizations rely on custom applications and web sites to be able to provide services, but unlike large companies they lack the funds and resources to keep these applications up to date or build them at all.&lt;/p&gt;
&lt;p&gt;On July 11-13 you have the opportunity to help out by participating in the &lt;a target="_blank" href="http://annarborgivecamp.org"&gt;Ann Arbor Give Camp&lt;/a&gt; and using your powers for good instead of evil!&lt;/p&gt;&lt;img src="http://jamescbender.com/bendersblog/aggbug/20.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Bender</dc:creator>
            <guid>http://jamescbender.com/bendersblog/archive/2008/06/23/give-camp.aspx</guid>
            <pubDate>Mon, 23 Jun 2008 15:11:59 GMT</pubDate>
            <wfw:comment>http://jamescbender.com/bendersblog/comments/20.aspx</wfw:comment>
            <comments>http://jamescbender.com/bendersblog/archive/2008/06/23/give-camp.aspx#feedback</comments>
            <wfw:commentRss>http://jamescbender.com/bendersblog/comments/commentRss/20.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Lansing, Here I Come!</title>
            <link>http://jamescbender.com/bendersblog/archive/2008/06/20/lansing-here-i-come.aspx</link>
            <description>&lt;p&gt;OK, short notice. Sorry about that... &lt;/p&gt;  &lt;p&gt;For those of you in the area I will be speaking at the Lansing Day of .NET tomorrow, June 21. I will be presenting "Getting Started with WCF."&lt;/p&gt;  &lt;p&gt;Hope to see you all there! &lt;/p&gt; &lt;a href="http://www.dayofdotnet.org/Lansing/"&gt;&lt;img alt="Lansing Day of .Net, 21 June 2008 - I'll be there!" src="http://www.dayofdotnet.org/Lansing/2008/images/ldodn-200x100.png" border="0" /&gt;&lt;/a&gt;&lt;img src="http://jamescbender.com/bendersblog/aggbug/19.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Bender</dc:creator>
            <guid>http://jamescbender.com/bendersblog/archive/2008/06/20/lansing-here-i-come.aspx</guid>
            <pubDate>Fri, 20 Jun 2008 18:09:20 GMT</pubDate>
            <wfw:comment>http://jamescbender.com/bendersblog/comments/19.aspx</wfw:comment>
            <comments>http://jamescbender.com/bendersblog/archive/2008/06/20/lansing-here-i-come.aspx#feedback</comments>
            <wfw:commentRss>http://jamescbender.com/bendersblog/comments/commentRss/19.aspx</wfw:commentRss>
        </item>
        <item>
            <title>SVCUTIL, you're my hero!</title>
            <link>http://jamescbender.com/bendersblog/archive/2008/05/15/svcutil-youre-my-hero.aspx</link>
            <description>&lt;p&gt;While I was putting my demos together for &lt;a href="http://www.clevelanddodn.org/" target="_blank"&gt;Cleveland Day of .NET&lt;/a&gt; I discovered a very frustrating, undocumented "feature" with the way the "Add Service Reference..." option works in Visual Studio 2008.&lt;/p&gt;  &lt;h2&gt;SPOILER ALERT!&lt;/h2&gt;  &lt;p&gt;My presentation is about custom behaviors, and one of my examples in an implementation of IInstanceProvider applied as an IServiceBehavior and added to my service runtime via code. I've done this a dozen times before with no issue, but this time something was amiss...&lt;/p&gt;  &lt;p&gt;I wrote my code, fired up my application and saw the behavior "appear" to bind to my runtime. I ran my client and the call to the service worked. The only problem is that my behavior was not executed.&lt;/p&gt;  &lt;p&gt;I had no idea what I could have done wrong. Like I said, I've done this dozens of times before with no issue. I went back and studied those old applications. Sure enough, they all still worked as expected. I started going line by line to see if there was ANYTHING I could have missed. Nothing.&lt;/p&gt;  &lt;p&gt;Then I noticed one difference; usually I used SVCUTIL to create my proxies and add them to my client application. This time, in the interest of keeping the demo "easy" I used the "Add service reference" option from Visual Studio. In all other ways it seemed to work, but I couldn't escape the fact that it was the ONLY difference between the two solutions.&lt;/p&gt;  &lt;p&gt;I tried a few more things around the service reference. I regenerated the reference. Nothing. I thought that maybe it was somehow calling the service before the behavior was bound (I know, kind of crazy but after 90 minutes I was started to get a little desperate). So I started the host manually, waited till I was SURE that the behavior was bound, then started the client. Nothing. &lt;/p&gt;  &lt;p&gt;So, having exhausted all other ideas, I dropped the VS created service reference and used SVCUTIL to create a proxy object and an application configuration file. I added them to my client project, fired up the service, made my service call and... it worked!&lt;/p&gt;  &lt;p&gt;Not being totally familiar with how VS creates the service references, I can't say for sure why it doesn't work. But, given that the behavior works when called from client that creates the channel stack (either manually via a generated proxy), I'm guessing that the service reference option is building this channel stack in a different way or somehow circumventing the aspects of the runtime on the service side. &lt;/p&gt;  &lt;p&gt;I've never deployed an application with VS generated service references, so I'm not sure how it works in production. Or if it's even possible to deploy a WCF client in such a way. Nor have I heard of anyone else doing it. &lt;/p&gt;  &lt;p&gt;To be honest, I prefer SVCUTIL proxies or developer written invocations of the channel stack. It gives you more control over how your client interacts with the service and if something does go horribly wrong I can debug into the stack and see what's going on. &lt;/p&gt;  &lt;p&gt;So Mr. "Add Service Reference..." I've given you a chance, but I think I'll stick with SVCUTIL.&lt;/p&gt;  &lt;p&gt;See you all at CDoDN!&lt;/p&gt;&lt;img src="http://jamescbender.com/bendersblog/aggbug/18.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Bender</dc:creator>
            <guid>http://jamescbender.com/bendersblog/archive/2008/05/15/svcutil-youre-my-hero.aspx</guid>
            <pubDate>Thu, 15 May 2008 14:52:07 GMT</pubDate>
            <wfw:comment>http://jamescbender.com/bendersblog/comments/18.aspx</wfw:comment>
            <comments>http://jamescbender.com/bendersblog/archive/2008/05/15/svcutil-youre-my-hero.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://jamescbender.com/bendersblog/comments/commentRss/18.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Pimp Your WCF Runtime - Episode One</title>
            <category>.NET</category>
            <category>WCF</category>
            <link>http://jamescbender.com/bendersblog/archive/2008/05/06/pimp-your-wcf-runtime---episode-one.aspx</link>
            <description>&lt;p&gt;If you have ever made any effort in learning WCF, you have probably seen some variation of this:&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;pre class="code"&gt;&lt;span style="color: blue"&gt;static void &lt;/span&gt;Main(&lt;span style="color: blue"&gt;string&lt;/span&gt;[] args)
{
    &lt;span style="color: #2b91af"&gt;ServiceHost &lt;/span&gt;host = &lt;span style="color: blue"&gt;null&lt;/span&gt;;
    &lt;span style="color: blue"&gt;try
    &lt;/span&gt;{
        host = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ServiceHost&lt;/span&gt;(&lt;span style="color: blue"&gt;typeof &lt;/span&gt;(&lt;span style="color: #2b91af"&gt;HelloWCF&lt;/span&gt;), &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"http://localhost:8080/HelloWCF"&lt;/span&gt;));
        host.Description.Endpoints[0].Behaviors.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyCustomMessageFormatter&lt;/span&gt;(&lt;span style="color: #a31515"&gt;"message"&lt;/span&gt;));
        host.Description.Behaviors.Add(&lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyInstanceProvider&lt;/span&gt;());

        host.Opening += host_Opening;
        host.Opened += host_Opened;
        host.Faulted += host_Faulted;

        host.Open();

        &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Service is available."&lt;/span&gt;);

        &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.ReadKey();
    }
    &lt;span style="color: blue"&gt;finally
    &lt;/span&gt;{
        &lt;span style="color: blue"&gt;if &lt;/span&gt;(host != &lt;span style="color: blue"&gt;null&lt;/span&gt;)
        {
            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Closing service..."&lt;/span&gt;);
            host.Close();
        }
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;This hosting code, or some variant of it, appears in almost every book on WCF, usually in a console application. It demonstrates creating an instance of ServiceHost for a service implementation (in this case HelloWCF) with a specified URI. A couple of behaviors are added at runtime and we wire up some custom event handlers. All in all, for WCF, nothing complicated.&lt;/p&gt;

&lt;p&gt;But what if you want to host your service in IIS? Since it comes with Windows Activation Service (WAS), IIS7 is an ideal environment to host your WCF service. So how do we get the same ability to customize our runtime in IIS?&lt;/p&gt;

&lt;p&gt;It's actually pretty easy.&lt;/p&gt;

&lt;h2&gt;System.ServiceModel.Activation to the rescue!&lt;/h2&gt;

&lt;p&gt;IIS uses an instance of a ServiceHostFactory to create a runtime for your hosted service. If you do not provide an implementation for this class, IIS will provide you with a default implementation.&lt;/p&gt;

&lt;p&gt;If we want to use are own hosting logic, all we have to do is create our own host class which inherits from ServiceHostFactory like so:&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyCustomHost &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;ServiceHostFactory
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;public override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ServiceHostBase &lt;/span&gt;CreateServiceHost(&lt;span style="color: blue"&gt;string &lt;/span&gt;constructorString, &lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;[] baseAddresses)
    {
        &lt;span style="color: blue"&gt;string &lt;/span&gt;serviceType = 
            &lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"{0}, {1}"&lt;/span&gt;, constructorString,
            constructorString.Substring(0, constructorString.IndexOf(&lt;span style="color: #a31515"&gt;"."&lt;/span&gt;)));

        &lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;t =&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;.GetType(serviceType);
        
        &lt;span style="color: #2b91af"&gt;ServiceHost &lt;/span&gt;host = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ServiceHost&lt;/span&gt;(t, baseAddresses);

        &lt;span style="color: blue"&gt;return &lt;/span&gt;host;
    }

    &lt;span style="color: blue"&gt;protected override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ServiceHost &lt;/span&gt;CreateServiceHost(&lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;serviceType, &lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;[] baseAddresses)
    {
        &lt;span style="color: #2b91af"&gt;ServiceHost &lt;/span&gt;host = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ServiceHost&lt;/span&gt;(serviceType, baseAddresses);

        &lt;span style="color: blue"&gt;return &lt;/span&gt;host;
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;When we do this we need to override both implementations of CreateServiceHost, which is the method IIS calls to create the runtime for you service. For both versions we get a service type and an array of base addresses. The only real difference between the two is that the version that takes the string as the first argument is taking the service type information as a string as opposed to a .NET Type. It's an easy matter to take this string and create an instance of a Type object, in which case we can refactor the code to this:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyCustomHost &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;ServiceHostFactory
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;public override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ServiceHostBase &lt;/span&gt;CreateServiceHost(&lt;span style="color: blue"&gt;string &lt;/span&gt;constructorString, &lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;[] baseAddresses)
    {
        &lt;span style="color: blue"&gt;string &lt;/span&gt;serviceType = 
            &lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"{0}, {1}"&lt;/span&gt;, constructorString,
            constructorString.Substring(0, constructorString.IndexOf(&lt;span style="color: #a31515"&gt;"."&lt;/span&gt;)));

        &lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;t =&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;.GetType(serviceType);
        
        &lt;span style="color: blue"&gt;return this&lt;/span&gt;.CreateServiceHost(t, baseAddresses);
    }

    &lt;span style="color: blue"&gt;protected override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ServiceHost &lt;/span&gt;CreateServiceHost(&lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;serviceType, &lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;[] baseAddresses)
    {
        &lt;span style="color: #2b91af"&gt;ServiceHost &lt;/span&gt;host = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ServiceHost&lt;/span&gt;(serviceType, baseAddresses);

        &lt;span style="color: blue"&gt;return &lt;/span&gt;host;
    }
}&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;I think this is a better way to handle this as you are able to keep all the specialized host creation logic to the second method. For example, lets add the events from the first example:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;MyCustomHost &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;ServiceHostFactory
&lt;/span&gt;{
    &lt;span style="color: blue"&gt;public override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ServiceHostBase &lt;/span&gt;CreateServiceHost(&lt;span style="color: blue"&gt;string &lt;/span&gt;constructorString, &lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;[] baseAddresses)
    {
        &lt;span style="color: blue"&gt;string &lt;/span&gt;serviceType = 
            &lt;span style="color: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="color: #a31515"&gt;"{0}, {1}"&lt;/span&gt;, constructorString,
            constructorString.Substring(0, constructorString.IndexOf(&lt;span style="color: #a31515"&gt;"."&lt;/span&gt;)));

        &lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;t =&lt;span style="color: #2b91af"&gt;Type&lt;/span&gt;.GetType(serviceType);
        
        &lt;span style="color: blue"&gt;return this&lt;/span&gt;.CreateServiceHost(t, baseAddresses);
    }

    &lt;span style="color: blue"&gt;protected override &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ServiceHost &lt;/span&gt;CreateServiceHost(&lt;span style="color: #2b91af"&gt;Type &lt;/span&gt;serviceType, &lt;span style="color: #2b91af"&gt;Uri&lt;/span&gt;[] baseAddresses)
    {
        &lt;span style="color: #2b91af"&gt;ServiceHost &lt;/span&gt;host = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ServiceHost&lt;/span&gt;(serviceType, baseAddresses);

        host.Opening += host_Opening;
        host.Opened += host_Opened;
        host.Faulted += host_Faulted;
        &lt;span style="color: blue"&gt;return &lt;/span&gt;host;
    }

    &lt;span style="color: blue"&gt;void &lt;/span&gt;host_Faulted(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;EventArgs &lt;/span&gt;e)
    {
        &lt;span style="color: green"&gt;// Some logic...
    &lt;/span&gt;}

    &lt;span style="color: blue"&gt;void &lt;/span&gt;host_Opened(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;EventArgs &lt;/span&gt;e)
    {
        &lt;span style="color: green"&gt;// Some logic...
    &lt;/span&gt;}

    &lt;span style="color: blue"&gt;void &lt;/span&gt;host_Opening(&lt;span style="color: blue"&gt;object &lt;/span&gt;sender, &lt;span style="color: #2b91af"&gt;EventArgs &lt;/span&gt;e)
    {
        &lt;span style="color: green"&gt;// Some logic...
    &lt;/span&gt;}
}&lt;/pre&gt;

&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;See, nothing to it!&lt;/p&gt;

&lt;p&gt;All that's left is hook this up to our SVC file.&lt;/p&gt;

&lt;p&gt;Unfortunately in Visual Studio 2008 it can be a little difficult to edit the SVC file. Double clicking it brings up the code behind file and not the SVC file. To get to that file, right click the file in the Solution Explorer and select "Open with..." Select "XML Editor" from the list and you should see something that looks like this:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;%&lt;span style="color: #a31515"&gt;@ &lt;/span&gt;&lt;span style="color: red"&gt;ServiceHost Language&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;C#&lt;/span&gt;" &lt;span style="color: red"&gt;Debug&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;true&lt;/span&gt;" &lt;span style="color: red"&gt;Service&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;CustomHostExample.Service1&lt;/span&gt;" &lt;span style="color: red"&gt;CodeBehind&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Service1.svc.cs&lt;/span&gt;" %&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;To add our service host, we just add a Factory attribute that identifies our service host:&lt;/p&gt;

&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&amp;lt;&lt;/span&gt;%&lt;span style="color: #a31515"&gt;@ &lt;/span&gt;&lt;span style="color: red"&gt;ServiceHost Language&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;C#&lt;/span&gt;" &lt;span style="color: red"&gt;Debug&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;true&lt;/span&gt;" &lt;span style="color: red"&gt;Service&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;CustomHostExample.Service1&lt;/span&gt;" 
    &lt;span style="color: red"&gt;CodeBehind&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;Service1.svc.cs&lt;/span&gt;" &lt;span style="color: red"&gt;Factory&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;CustomHostExample.MyCustomHost&lt;/span&gt;" %&lt;span style="color: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;

&lt;p&gt;Save the SVC file and that's it! You just customized your IIS runtime environment for you WCF service.&lt;/p&gt;&lt;img src="http://jamescbender.com/bendersblog/aggbug/17.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Bender</dc:creator>
            <guid>http://jamescbender.com/bendersblog/archive/2008/05/06/pimp-your-wcf-runtime---episode-one.aspx</guid>
            <pubDate>Wed, 07 May 2008 01:32:09 GMT</pubDate>
            <wfw:comment>http://jamescbender.com/bendersblog/comments/17.aspx</wfw:comment>
            <comments>http://jamescbender.com/bendersblog/archive/2008/05/06/pimp-your-wcf-runtime---episode-one.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://jamescbender.com/bendersblog/comments/commentRss/17.aspx</wfw:commentRss>
        </item>
        <item>
            <title>Reliable Messaging at CODODN</title>
            <category>Day of .NET</category>
            <category>Shameless self promotion</category>
            <category>WCF</category>
            <link>http://jamescbender.com/bendersblog/archive/2008/04/22/reliable-messaging-at-cododn.aspx</link>
            <description>&lt;p&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; margin: 0px 10px 0px 0px; border-right-width: 0px" height="303" alt="thank-you" src="http://customersrock.files.wordpress.com/2007/05/thank-you.jpg" width="203" align="left" border="0" /&gt;&lt;/p&gt;  &lt;p&gt;Thanks to everyone who came to either my F# talk with &lt;a href="http://www.panadmonial.com" target="_blank"&gt;Amanda Laucher&lt;/a&gt; or my Reliable Messaging talk. If you came to both than EXTRA THANKS!  &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;As promised, here is a link to my slides and sample code from the WCF talk.&lt;/p&gt;  &lt;p&gt;&lt;iframe style="border-right: #dde5e9 1px solid; padding-right: 0px; border-top: #dde5e9 1px solid; padding-left: 0px; padding-bottom: 0px; margin: 3px; border-left: #dde5e9 1px solid; width: 240px; padding-top: 0px; border-bottom: #dde5e9 1px solid; height: 66px; background-color: #ffffff" marginwidth="0" marginheight="0" src="http://cid-de4aebf19948423f.skydrive.live.com/embedrowdetail.aspx/Public/Presentation%20Slides/Reliable%20Messaging%20with%20WCF/Reliable%20Messaging%20with%20WCF%20-%20CODODN.zip" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;For those of you who missed it, I will be presenting the same talk at the Western Michigan Day of .NET in Grand Rapids on May 10th.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.wmdotnet.org/dodn08/"&gt;&lt;img alt="WM Day of .Net May 10, 2008 - I'll be there!" src="http://www.wmdotnet.org/DODN08/images/Site-Badge-I.gif" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt; &lt;/p&gt;  &lt;p&gt;See you all there!&lt;/p&gt;&lt;img src="http://jamescbender.com/bendersblog/aggbug/16.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>James Bender</dc:creator>
            <guid>http://jamescbender.com/bendersblog/archive/2008/04/22/reliable-messaging-at-cododn.aspx</guid>
            <pubDate>Tue, 22 Apr 2008 14:22:55 GMT</pubDate>
            <wfw:comment>http://jamescbender.com/bendersblog/comments/16.aspx</wfw:comment>
            <comments>http://jamescbender.com/bendersblog/archive/2008/04/22/reliable-messaging-at-cododn.aspx#feedback</comments>
            <wfw:commentRss>http://jamescbender.com/bendersblog/comments/commentRss/16.aspx</wfw:commentRss>
        </item>
    </channel>
</rss>
