Jun 06, 2007

My blog has moved

My blog has moved over to dasBlog and can be found Here

Jun 05, 2007

Sorry for the loss of service

My blog has been dead for a while due to someone managing to enter a comment that broke the very old blog engine I use (BlogX). Now I have this fixed I will also look at moving to a more modern blog engine ... watch this space

Feb 12, 2007

The connected systems roadshow goes to Dublin

We're running another Connected Systems Roadshow in Dublin next week.It is being held at the Berkley Court Hotel on the 21st February starting at 10:00am. We'll be talking about using WCF, BizTalk and SQL Service Broker in distributed systems.

If you would like to attend please register here.

An other successful UK BizTalk User Group meeting

The second meeting of the UK BizTalk User Group took place in London on February 6th. We had talks on Using BAM for realtime aggregation and RFID. Many thanks to Ben Goeltz and Simon Holloway for those talks. The next meeting date has yet to be announced but should be sometime in May (as long as we can find a venue as the Microsoft office in Great Poultney Street, where we have run both of the meetings so far, is closing down). I'll post an update when I have got more concrete details for date and venue.

Dec 01, 2006

Connected Systems Roadshow Slides and Demos

Thanks to everyone that attended the DM Connected Systems Roadshow in TVP over the last two days myself, Niels and Dom had a blast.

As I promised, the slides and demos from the track me and Niels did are now available here. Dom's track materials are linked from here.

Onwards to the next roadshow - watch this space for details

Oct 08, 2006

WCF Self hosting snippet

While teaching Essential WCF last week I got sick of creating the skeleton for a simple self hosted service. Dom (who was co-teaching with me) suggested I write a snippet for it. This is what I came up with:

<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Title>servicehost</Title>
            <Shortcut>servicehost</Shortcut>
            <Description>Code snippet for creating a simple service</Description>
            <Author>Richard Blewett</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
        <Literal>
          <ID>namespace</ID>
          <ToolTip>Namespace</ToolTip>
          <Default>Service</Default>
        </Literal>
        <Literal>
                    <ID>contract</ID>
                    <ToolTip>Contract name</ToolTip>
                    <Default>IContract</Default>
                </Literal>
                <Literal>
                    <ID>service</ID>
                    <ToolTip>Service implementation</ToolTip>
                    <Default>Service</Default>
                </Literal>
                <Literal>
                    <ID>field</ID>
                    <ToolTip>The variable backing this property</ToolTip>
                    <Default>myVar</Default>
                </Literal>
            </Declarations>
            <Code Language="csharp">
        <![CDATA[using System;
using System.Collections.Generic;
using System.Text;
using System.ServiceModel;

namespace $namespace$
{
    [ServiceContract]
    interface $contract$
    {
        [OperationContract]
        void Method();
    }

    class $service$ : $contract$$end$
    {
    }

    class Program
    {
        static void Main(string[] args)
        {
            using (ServiceHost host = new ServiceHost(typeof($service$), new Uri("http://localhost/$service$")))
            {
                host.Open();

                Console.WriteLine("Service Ready ...");
                Console.ReadLine();

                host.Close();
            }
        }
    }

}
]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>

Hopefully someone will find this useful

Something strange with the NetPeerTcpBinding validator

I've been head down in WCF for a while now, culminating with teaching the first run of DevelopMentor's Essential WCF course last week.

After the Peer to Peer session I was talking to one of the students about the possiblity of using the technology for scenarios other than writing your own version of Windows Live Messenger (which is what all the demos seem to do). I decided to have a play around and along the way discovered a bug in the NetPeerTcpBinding validator.

I'd defined by config file thus:

<bindings>
<netPeerTcpBinding>
<binding name="peer" port="0">
<resolver mode="Custom">
<custom address="http://localhost/stockPeerResolver"
binding="basicHttpBinding" />
</resolver>
<security mode="None" />
</binding>
</netPeerTcpBinding>
</bindings>

The problem was I kept getting an error everytime I tried to create my DuplexChannel. The error read:

"Specified resolver settings are not enough to create a valid resolver.  Please ensure that a ResolverType and an Address is specified for the custom resolver."

Now, since I was developing on Win2003 I had to write my own Peer Resolver (PNRP isn't available on Win2003). However, I was using WCF to get to the resolver so I didn;t actually need to specify a custom type in the binding - just the address and binding to get to the resolver. After puzzling about this for some time - looking at another example I had that was working - I discovered some very strange behavior. Everything works if I modify the config file as folllows:

<bindings>
<netPeerTcpBinding>
<binding name="peer" port="0">
<resolver mode="Custom">
<custom address="http://localhost/stockPeerResolver"
binding="basicHttpBinding"
bindingConfiguration="wtf"/>
</resolver>
<security mode="None" />
</binding>
</netPeerTcpBinding>
<basicHttpBinding>
<binding name="wtf" />
</basicHttpBinding>
</bindings>

So I had to add a reference to a binding configuration that did nothing and it all suddenly works, even though the channel stack is built exactly the same.

It lives!

Well its been a long time since I blogged so its time to get back into the groove. Hopefully this time I'll make more regular posts.

Mar 30, 2006

Hmmm ... where have my menu items gone?

I worked with the carnage that was the complex relationship between VS2005 and SQL 2005 betas and CTPs for pretty much the entire beta cycle and got used to strange thinngs happening in the VS IDE. On release I  installed the  RTM bits and everything looked fine. However, teaching for DevelopMentor I frequently end up using machines that I haven't myself configured. I started to notice that the menus were sometimes different and took this to be that they were different because I was debugging / editing a certain file type / etc.

However, at a recent Guerrilla.NET we had a conflict between the lab instructions and VS setup that meant we had to investigate why a menu item wasn't appearing. It turns out there are two important decisions that affect your menus. The first is the question that you answer when you use VS for the first time "what kind of developer are you" and depending on what you select you get tuned menus. I believe that selecting "Visual Studio Developer" gets you the full set.

The second issue is more subtle though. The order in which you install SQL Server 2005 and VS 2005 is significant. SQL Server 2005 can install the Business Intelligence Workbench which is hosted in the VS shell. If you install SQL Server 2005 first you may find that your menus are restricted to the BI Workbench items (an example of this is having only two items on your Debug menu).

The remedy to this is not obvious. I spent some time trawling through the Tools/Options dialog to no avail. Finally I discovered the feature was controlled by Tools / Import and Export Settings. If you choose to import to you can import one of the other configurations. Hopefully this post will save others some time and frustration.

Mar 07, 2006

Thread.Abort still considered harmful

Back in the days of .NET 1.1 there was a nasty issue with Thread.Abort where the ThreadAbortException could be thrown out of a finally block this was one of the reasons you should not have called Thread.Abort in 1.1. For v2.0 this no longer happens, however, this can have its own issues. Consider the following code:

    class Program
    {
        static void Main(string[] args)
        {
            Thread t = new Thread(DoWork);

            t.IsBackground = true;
            t.Start();

            Thread.Sleep(500);
        }

        static void DoWork()
        {
            try
            {
            }
            finally
            {
                while (true)
                {
                    Console.Write(".");
                    Thread.Sleep(200);
                }
            }
        }
    }

This terminates quite happly as the thread is a back ground thread. Now lets change the code slightly:

    class Program
    {
        static void Main(string[] args)
        {
            Thread t = new Thread(DoWork);

            t.IsBackground = true;
            t.Start();

            Thread.Sleep(500);

            Console.WriteLine("aborting");
            t.Abort();
        }

        static void DoWork()
        {
            try
            {
            }
            finally
            {
                while (true)
                {
                    Console.Write(".");
                    Thread.Sleep(200);
                }
            }
        }
    }

All we've done here is abort the thread. However, because the Abort will not take place until the thread is out of the finally block, Abort does not return and so the program now doesn't terminate at all. So even though some of the problems with Thread.Abort have been fixed you still shouldn't call this API.