The Windows Vista WOW has Started

As the clock strikes midnight around the world, signs of the consumer release of Windows
Vista have started to surface.

Pick a WOW any WOW!

Retailers have started getting their displays ready, with many of them holding special
launch celebrations



And some even have systems with Vista pre-loaded ready to go.


tags: , ,

WCF: This collection already contains an address with scheme http

The Problem:

I recently ran into this problem issue trying to host a service through my shared
web hosting service provider.

Server Error in ‘/’ Application.

This collection already contains an address with scheme http. There can be
at most one address per scheme in this collection.

Parameter name: item

Description: An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about the error and
where it originated in the code.

Exception Details: System.ArgumentException: This collection already contains
an address with scheme http. There can be at most one address per scheme in this collection.

Parameter name: item

The Solution:

The solution, since WCF services hosted in IIS can have only one Base Address was
to create a custom service factory to intercept and remove the additional unwanted
base addresses that IIS was providing. In my case IIS was providing:

We are able to customize our .svc file to specif a custom serive factory

<%@ServiceHost language=c# Debug="true" Service="Microsoft.ServiceModel.Samples.CalculatorService"
Factory="Microsoft.ServiceModel.Samples.CustomHostFactory" %>

We are then able to create our custom factory by inheriting from ServiceHostFactory
and overriding as required

    class CustomHostFactory : ServiceHostFactory
{ protected override ServiceHost
CreateServiceHost(Type serviceType, Uri[] baseAddresses) { CustomHost customServiceHost
= new CustomHost(serviceType, baseAddresses[1]); return customServiceHost;
} } class CustomHost : ServiceHost { public CustomHost(Type
serviceType, params Uri[] baseAddresses) : base(serviceType,
baseAddresses) { } protected override void ApplyConfiguration()
{ base.ApplyConfiguration(); } }

In my case I decided to pass through baseAddresses[1] (which was the www. address)
but it would probably be wise to specify that address you want to prevent changes
by your web host from impacting yoru code.

Big thanks to those at WebHost4Life that
put the time into helping me resolve this.


TimeLinePanel – Custom WPF Control Part 2

So Dwayne tells me that my Timeline Panel is in desperate need of a graphics artist.
Ouch. While it didn’t actually hurt my feelings, it was good motivation to get Part
2 online here which shows that the screenshot I left you all with of the basic timeline
was really just showing the functionality of organizing textblock elements based on
their event date.

In order to do the layout I override the ArrangeOverride method and introduce my own
code to adjust the horizontal positioning. I utilize a ConvertDateToPosition function
in which I calculate the _eventDate’s position relative to the start and end dates
provided to the panel. This could be inferred from the child dates but I decided to
allow this to be set independently.

        protected override System.Windows.Size ArrangeOverride(System.Windows.Size finalSize)
{ foreach (UIElement child in base.InternalChildren)
{ Size sizeChild = new Size(child.DesiredSize.Width,
child.DesiredSize.Height); DateTime _eventDate
= (DateTime)child.GetValue(EventDateProperty); double NewSize
= ConvertDateToPosition(_eventDate, _startDate, _endDate); NewSize = NewSize*finalSize.Width;

           child.Arrange(new Rect(ptChild,
sizeChild)); } return finalSize;

Now the cool thing about the way that XAML and WPF handle child elements is that they
can be of any type. Initially I used boring text boxes, but they could be Ellipses….

Or buttons…

Really any element could be used. The next step to follow my original Kayakalon example
was to have the width of the elements determined as well by the end date provided.
This would allow a more visual indication of the time spans.

To do this, I used the same ConvertDateToPosition function mentioned above to to calculate
a new width for the child element which is inserted in the Child.Arrange call that
executes for each child element during the ArrangeOveride method.

Before I forget, I wanted to mention that I also added some code in the arrange method
to vertically stack the elements if their dates overlapped. This was done by tracking
the potion and width of the last child element to see if the next one overlapped and
if so increase it’s vertical position. I also added the tick marks along the top by
overriding the OnRender event.

Now I need to go make my hip shiny, trendy colored version of this for Dwayne.

tags: , ,

Blog Tag, I’m it?

If this had shown up in an email I would have just deleted it, but I’ll join in after
the tag
from Matt.
In the spirit of blogs, here are 5 lesser know things about me.

1. My first computer was a Commodore 64. Followed by an Amiga 1000, then 2000, 3000T
and finally 4000 before the demise of Commodore. I admit it, I used to think DOS/Windows

2. I lapped the score in Astroids on my Atari 2600 not once, but twice in one sitting.
I can’t recall how long it took, but do remember being yelled at for missing at least
two meals.

3. In 1994(?) I was responsible for bringing internet access to our city and surrounding
areas. We started with a 128k frame relay connection and 10 US Robotics Sportster
28.8 modems.

4. I have a cat that can say her own name. (Mew)

5. I’m lame and can’t stand games like this appearing all over the place so I decline
any further “Tag”ing

TRINUG – Guest Speaker Juval Lowy

 Sorry for the late notice, but I just got back to town myself…. Juval Lowy
will be speaking at the Triangle .Net User Group meeting TOMORROW Wednesday Jan 10th.
This is one of those must see presentations.

Speaker: Juval Lowy

Programming Windows Communication Foundation – a Developer’s Primer

How do you actually build and consume WCF-based services? At its core, the WCF programming
model is simple and straightforward, requiring actually very little work on behalf
of the developer. The session describes the essential WCF programming concepts: clients,
services, contracts and end points, and shows how to build, configure and host simple
services. After attending this session you will be able to start programming and exploring

Source: Triangle Dot Net Users Group > Home

Please also note the NEW MEETING LOCATION!


tags: , ,

TimeLinePanel – Custom WPF Control Part 1

Frequently when I see a new technology presented, there are often demos of key concepts
that stick in my mind. These examples become things that I feel I must try to build
and thoroughly understand myself. At Microsoft’s Tech Ed conference in Boston back
in June, one of the demos that really stuck with me was the “Kayakalon” demo application
used in presentations by Robert Ingebretsen and Lauren
from the WPF team.

The demo application touched on a number of items revolving around the graphical display
of airline flight searches returned from a web service. The end result would
display flight legs on a graphical time line.

The creation of this TimeLinePanel become a task on the learning list to help me understand.
I began trying to recreate the functionality of the control. I started off by inheriting
from a Panel control to build a custom panel that would horizontally position child
elements based on date criteria.

public class TimeLinePanel : Panel


protected override System.Windows.Size ArrangeOverride(System.Windows.Size finalSize)


return base.ArrangeOverride(finalSize);


protected override System.Windows.Size MeasureOverride(System.Windows.Size availableSize)


return base.MeasureOverride(availableSize);



In order to handle the layout as required, we are able to override the ArrangeOverride
and MeasureOverride methods. The MeasureOverride measures the size in layout required
for child elements and determines a size for the element. The ArrangeOverride positions
child elements and determines their size. What I wanted to do was to horizontally
position the elements based two dates, the would become the start and stop dates for
each object, or in the case of the above example the departure and arrival times of
the flight legs. In order to take advantage of a WPF design, enabling me to put any
type of child elements into this panel, I needed some way to attached these properties
to any objects residing in this container, even if they had not concept of these dates.

In .Net 3.0, Microsoft introduces the concept of a DependencyProperty according to
the docs “Represents properties that are registered with the Windows Presentation
Foundation dependency property system. Dependency properties provide support for value
expressions, property invalidation and dependent-value coercion, default values, inheritance,
data binding, animation, property change notification, and styling. This class cannot
be inherited.”

More specifically, I want to make use of an attached property which is “A dependency
property that can be attached to any DependencyObject type and that is not limited
to the type which defines it. The attached property provider must provide a static
get(PropertyName) and set(PropertyName) methods as accessors for these attached properties.”
So basically, in the end I can create a two properties, independent of their actual
types, allowing me to define a start and end date that get attached to any child elements
with default values, that can be changed. Through these I can control the layout of
the controls.

public static DependencyProperty EventDateProperty;

public static DependencyProperty EventDateRangeProperty;

static TimeLinePanel()


FrameworkPropertyMetadata metadata = new FrameworkPropertyMetadata(DateTime.Parse(“1/1/0001”), FrameworkPropertyMetadataOptions.Inherits

FrameworkPropertyMetadata metadataB = new FrameworkPropertyMetadata(DateTime.Parse(“1/1/0001”), FrameworkPropertyMetadataOptions.Inherits);

EventDateProperty = DependencyProperty.RegisterAttached(“EventDate”,

typeof(DateTime), typeof(Control),metadata);

EventDateRangeProperty = DependencyProperty.RegisterAttached(“EventDateRange”,

typeof(DateTime), typeof(Control),


public static void SetEventDate(DependencyObject dependencyObject, DateTime eventdate)


dependencyObject.SetValue(EventDateProperty, eventdate);


public static void SetEventDateRange(DependencyObject dependencyObject, DateTime eventdaterange)


dependencyObject.SetValue(EventDateRangeProperty, eventdaterange);


Once these properties are in place, I can define my elements like this:

Windows 1.0

Windows 2.0

Windows 3.0

Windows 3.1

Windows NT 3.51

Windows 95

Windows NT 4

Windows 98

Windows 2000

Windows Me

Windows XP

Windows Vista

The end result renders like this:

Working through this example I discovered a lot of cool things that I could easily
do to add functionality to this control. The main take away is how you can control
how child elements are arranged.

tags: , , ,