This blog has, IMO, some great resources. Unfortunately, some of those resources are becoming less relevant. I'm still blogging, learning tech and helping others...please find me at my new home on

Wednesday, October 12, 2011

CustomBinding on Service Reference Results in TransportBindingElement Error

I’m coding an ASP.NET MVC 3 web site in Visual Studio 2010.  I added a service reference to a SOAP 1.2 version of a web service and started updating my code (I was using a SOAP 1.1 endpoint previously).

Unfortunately the switchover wasn’t as clean as I had hoped. The first method I changed resulted in an error, even on a call that appeared identical to the previous version. The error message I received was:

The CustomBinding on the ServiceEndpoint with contract 'SubscriberServices' lacks a TransportBindingElement.  Every binding must have at least one binding element that derives from TransportBindingElement.

…which looked like this:


For the quick fix, head to the end of this article.  Keep reading if you want to know what’s going on.

What Was Going On?

The two things that gave me the strongest clues where “CustomBinding” and “TransportBindingElement”, but for different reasons.  CustomBinding was a little unexpected as the service was added via HTTP. I guess I always assumed that it would be using an HTTP binding? The other piece suggested a derivative of the TransportBindingElement, which according to MSDN is an abstract base class.

Off to Our Config File

Actually, at this point, I wanted less noise, so I quickly created a console app and added references to both services.  The differences were, at this point, fairly obvious. The 1.1 version of the service was using a basicHttpBinding element (which I was expecting), whereas the 1.2 service was using a custom binding:


So, what we’re looking at is trying to get the custom binding to know which transport we want to use. This is something that is implicit in the basicHttpBinding but needs to be explicitly set for customBindings.

The Fix

Following the links on the TransportBindingElement will lead us to the httpTransportbindingElement, which has both code and config file samples.  Adding a short and simple section to the binding did the trick; all I needed was an httpTransport element in the customBinding\binding element. The updated config section looked like this with the MSDN sample config injected:


Further reading shows that all the properties set in the MSDN example are actually all defaults, which means that our httpTransport element can simply be reduced to a single, self-closing tag:



Quick Recap

So, in short, if you’re using a SOAP 1.2 service reference, or any service reference that requires the use of a custom binding, make sure you’ve added a TransportBindingElement (such as httpTransport) to your config file or in your code.

Thursday, October 6, 2011

Setting up ASP.NET MVC 3 to work with jQuery UI 1.9

Caution: I don't recommend trying this in a production environment. The branch of jQuery UI I'm using in this series is not considered stable and is not meant for prod releases.  You can, however, learn about the new features in the UI library and stretch your development capabilities!

The New and Juicy Bits

jQuery UI continues to impress. The development team's commitment to extensibility means that their own widgets are up for review at each release, and even at each milestone of a release.  The great thing about the modularity in jQuery UI is that you can build your own widgets or customize the existing ones with the very parts used to build the core set in the first place. 

But, before you even have to venture in that direction, you already have the ability to work with the many themes (or roll your own!) to make it look and feel the way you want to.

Focusing on stability and flexibility in the 1.9 build, here are some of the important bits that will be surfacing in this release of jQuery UI:

  • Improved, tested code in many of the existing widgets
  • Much better accessibility accross the suite (for disabled users/browsers)
  • Revisited the API design on a number of widgets (Button, Dialog, Position, ProgressBar, Slider, Tabs)
  • Improved collision detection on Position and added a new flipfit mode
  • A new version of Theme Roller, the download builder and the web site
  • New widgets: Tooltip, Spinner, Menu and Menubar


Here's the descriptions of the new Widgets from the horse's mouth:

  • Tooltip: A tooltip is a small overlay that sits over the main page that can be used to provide content or functionality that does not need to be always visible.
  • Spinner: A spinner (stepper) is a simple widget that allows users to increment or decrement the current text box value without having to input it manually.
  • Menu: Menu transform a list of anchors into a widget with mouse and keyboard support for selecting an item.
  • Menubar: A horizontal menu with nested vertical flyout menus for each menu item.


Getting jQuery UI 1.9

While I'm a huge fan of the integrated package manager in VS2010, you're not going to find these bits on Nuget.  You're going to either need to follow the links from the Milestone 6 post or grab the bits directly from

Once you grab the zip, unpack it and have a look at the contents.


Pretty much everything we're going to need will be in the UI and Themes directories.  If you're not familiar with jQuery UI, the Themes directory is where all the CSS is stored for making the entire UI has a consistant look-and-feel.  UI is where all the code exists for all components. 

You have the choice of building up your own set of functionality for the widgets you're using by including the smaller UI libraries, or you can fire up the full kit with one library.  This allows the bandwidth-concerned developer the opportunity to choose lighter weight code files (or even compile only the needed scripts into a minified script of their own creation).

As an example, if you wanted to make use of the new spinner, you'd need to include:

  • jquery.ui.core.js
  • jquery.ui.widget.js
  • jquery.ui.button.js
  • jquery.ui.spinner.js

Of course, you would also need to include the relevant CSS files, but with a total weight of 7Kb (and the option to use multiple CDNs out on the web) you might as well just include the full jQuery-ui.css.

Using jQuery UI 1.9 in ASP.NET MVC

I'm going to assume you've done a little MVC work before, if not, hold tight for the walkthrough after the bullet list. I'm using version 3 of the MVC Framework in Visual Studio 2010 SP1.

Here's the steps:

  1. Create a new MVC 3 project using the "Empty" template
  2. Delete the "themes" folder in Content
  3. Update jQuery with NuGet
  4. Add jQuery UI 1.9 files to the project ("themes" go in Content and "UI" go in Scripts)
  5. Add a HomeController
  6. Add an Index view for HomeController
  7. Modify the _Layout.cshtml file (your master page) to include jQuery UI and the theme CSS


Walking Through the Setup

Here's the visual play-by-play of that in action.

Creating and Cleaning up the Project

Open up Visual Studio 2010 and select File –> New Project.  Create a new ASP.NET MVC 3 Application.


Name the project and click OK.  Finally, select the “Empty” template from the list and click okay.


Navigate to the content folder at the root of the project and delete it.


Updating jQuery

Next, we need to get the latest version of jQuery so that jQuery UI 1.9 is happy with us.  Go to the Package Manager Console and type:

Update-Package jQuery

…and you’ll see the following:


NuGet (the heart of this console) happily goes off and updates all our dependencies for us.

Adding jQuery UI 1.9

Pop over to that zip folder you downloaded. You’ll need to make sure you’ve extracted all the files. Copy the themes directory, then switch over to VS2010 and paste it into the content folder.  Do the same with UI, but paste it as a sub folder into Scripts.


Adding the Controller and View

We’re going to use the tooling in MVC 3 to do the next bit of work for us, in particular, the code generation that creates controllers and views for us.  Right-click on the Controller folder, then select Add –> Controller.  Call it HomeController when the dialog prompts you (this is so that we can take advantage of the default routing rules in MVC).


Your HomeController class is automatically generated with the Index action created for you.  Right click on the name of this action and select Add View. Accept the default name (it picks Index for you because that’s the action you right-clicked).


Updating the Layout

Almost there!  All that’s left to do is to adjust our Layout.  The _Layout.cshtml file is like a MasterPage from our days of WebForms and we use it to inject our head element containing the script and CSS references. 

There’s already a jQuery reference there, so that needs to be update to the correct version (1.6.4 as at the time of this writing).  You’ll need to add the jquery-ui.css and jquery-ui.js files as well.


For you copy-and-pasters out there:

    <link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />     <script src="@Url.Content("~/Scripts/jquery-1.6.4.min.js")" type="text/javascript"></script>     <script src="@Url.Content("~/Scripts/ui/jquery-ui.js")" type="text/javascript"></script>

And that’s it! You’re all set up to use jQuery UI 1.9.

Next Up: Using the Spinner with Entity Metadata

Now that you’ve got the library in your project, we’re going to have look at some of the controls in more detail. One of the great things in MVC is the insanely simple templates and data binding, especially when coupled with something like Entity Framework.

Hold on to your hats, in the next segment we’re going to use data annotation attributes to wire up a jQuery UI Spinner widget!

Thursday, April 21, 2011

Time to Move On

I'm starting to chart a new course - still in software development, but trying to focus more on a couple of technologies in particular: Asp.Net MVC framework and the NuGet open source package manager.

As well, I'm going to start sharing my development experiences with other developers and aspiring developers at conferences, workshops and user group meetings.

You'll be able to find my new ramblings at my new site: which will be created with the open source Orchard project.

After being with Blogger for so many years (since 2003, I think?) it will be fun to be working on a new blog engine that is extensible and on the same platform that I develop on (.Net).

Thanks to the many 1000s of you who come here each month, dozens who leave comments and to those of you who have asked questions, made corrections or sent me towards resources I had otherwise overlooked.

Monday, April 4, 2011

Canadians Pay for Music

…but you have to let us at it.

In 2010 Canadians purchased 31.5 million albums.  Folks, that’s darn near the equivalent of one CD per person in the country.

I’m guessing the average album would have sold around the $10 mark.  A digital music store would have taken $3.33 of that.

I hate to continually flog the Zune folks here, but I fail to understand how there is absolutely NO UPDATE or additional information of music in the Zune Marketplace. I started following a few threads in the forums and it seems there is a rising level of frustration, more with the fact that there are no straight answers.

Like I’ve previously said, tell me who the hold up is, and I’d be happy to chase resolution.

This is a market worth 1/3 of a billion dollars, and one that will continue to grow when Canadians have access to reasonable digital content from multiple competitors at a fair price.

Friday, March 25, 2011

Problems with Diamond DisplayLink BVU160

I run a multi-monitor setup and love the extra real estate.  Unfortunately, due to an error in ordering my PC I ended up with a slim chasis and can’t find a dual-head card that fits. I resorted to using the Diamond USB adapter, which for the most part has been a nice way to get that third monitor running.

But lately this little guy has been causing me headaches.


Here’s the formula:

  • Windows 7 Ultimate x64
  • Diamond BVU160 v1.0 DisplayLink adapter, driver is up to date
  • Windows Phone 7 attached (Samsung Focus)
  • Dell E198FP monitor
  • ATI Radeon HD 3400 Series display drivers, up to date

The screen “freezes” up and does one of two things:

  1. The image is locked in a sense, and only redraws small invalidated regions as I drag my mouse across the monitor.  I can also restore a window, invalidating the whole screen, and get the whole thing to redraw.  This works a few times, but then the screen goes black.
  2. It skips #1 (or I just don’t notice as I’m working on a different monitor) and just goes black.

At this point I have to unplug the power of the monitor (power cycling doesn’t do anything, I have to physically remove the AC cable), disconnect the Diamond adapter, reconnect power and then attach the USB adapter again.

This is happening about 2-3 times a day when I have the phone connected and the display adapter is almost hot to the touch when it gets to this state.

I have a fairly high level of certainty that this is related to a conflict with Diamond’s adapter and Windows Phone.  It only ever freezes like this with the WP7 device attached.  I thought it was perhaps Folding@Home, but I uninstalled that and I’m still getting this problem.

If anyone else is running into this and has a workaround, please let me know!

Wednesday, March 23, 2011

How Windows Phone 7 Could Fail in Canada

Folks, let me start by saying that I love my Samsung Focus.  Everyone’s seen an iPhone by now, but you can still turn heads when you’re zipping through the home screen on a WP7 device.  The interface is slick, the apps you need are mostly in the marketplace and the cooler ones – I’m still waiting for the possibilities of augmented reality apps with video and compass APIs – are on the way.

The phone is well integrated into my other communication points, from email and messaging to scheduling and sharing, and though I’m a heavy user I’ve seen little by the way of bugs.

But I live in Canada.  And the sale of this phone platform to my friends will be tough.  It’s not because the platform isn’t great – and I do think WP7 phones are on a great platform – it’s because the phones in Canada are crippled.

The Show Me Factor

We are moving away from a people with music players to a people with multifunction devices that have music players on them.  At least, those of us with the ability to support a smartphone contract are.  Well, us and the teenagers whose parents spoil them, but I digress.  I had my first MP3 player over 10 years ago and haven’t missed it a bit.

But the music marketplace in Canada Sucks.  Yes, “sucks” with a capital “S”.  We have very limited choices in where we can purchase our digital content outside of the iVerse.  I’ve used Puretracks and played with the paid versions of some other services but not all the content I want is there and I’ve previously had troubles with DRM content on mulitple devices.

I want my family – we have four PCs all running Windows 7 as well our our Xbox 360 – to be able to use something more fluid within our ecosystem, connected to and built into the devices we use.

Including our phones.

Look, there’s going to be a point where people will have seen it/been there/done that and if the experience isn’t positive they won’t want to go there again.  There’s a really good, but shortening, window that Microsoft should be able to leverage.

The Switchover Debate

Look, if I can’t convince my wife, my soul mate, my partner until forever to buy a Windows Phone device then I’m not going to get too far with others.  These things should sell themselves, but this media marketplace keeps kicking WP7 in the face.

We’ve talked about the switch to a smart phone and she’s been leaning towards an iPhone for some time.  All of her music is in iTunes and we’d need to spend some time converting it (in some cases with DRM that might not be possible) and then we’d be left with the purchase void.

That chasm is too far to cross at the moment.  We’ve agreed to wait for a bit to see if the marketplace changes, but at this point it’s a wide open yawn’s worth of information available and no one is giving any updated information.  For fully three years we’ve been hearing “Keep checking the Zune web site for your region” and nothing more.

Challenge #1 - Marketing

I eagerly waited for the Zune HD here in Canada, only to have my hopes dashed when Future Shop pulled the remaining original Zune devices from the shelves.  A new employee said to me, literally three days after I almost bought one, that he’d never even heard of Zune.

What?!  How could that be?  How could the only device poised to be an iPod killer not even enter the general population’s vernacular? We are talking about a company who did the unthinkable here and broke into the video game industry, a move previously believed impossible as the market already had enough players.  How could, in this young and developing area with few serious players, Microsoft miss the boat with visibility?

The same thing seems to be happening with Windows Phone.  I can still walk into a room of people completely unaware that WP7 devices were actually out.

Challenge #2 – The Marketplace

This appears as #2 on my list, but not because it’s less important.  I will say this as directly as possible, Microsoft: the music marketplace must be fixed.

Technically, it’s not broken.  Because it’s not here.  This is the number one reason my wife won’t buy into the ecosystem, and it’s almost always one of the first things I’m asked of when I’m showing my phone.  You fire up Shazam and it’s right in your face: excellent execution followed by a lack of follow-through.

I am a sell out here, folks and I know it.  I’m a die hard.  This is a platform with great potential and I’ve even gone so far as to evaluate my “grey area” options (US credit card, friend’s address).  But I’d much rather see the ecosystem change for WP7 in Canada so that we can do things legitimately and without hassle.

I understand that there may be other problems.  I’ve heard everything from the CRTC blocking Microsoft, to third party licensing complications, to Apple threatening to make things messy.  But Microsoft hasn’t said peep squat about what the problems are.

Challenge #3 – Marketing

Yes, it’s the same as reason one, but different.  You see, the thing is that Apple didn’t sell it’s iPods to the millions of customers that have them.  The other customers did. Unfortunately, proud Canadians wielding their WP7 phones are ill-equipped to make the sale.

Heck, even the stores clerks aren’t really there as far as sales pitches.  When I asked to see the Focus at Future Shop, I was greeted with a, “Really? Why?”.  He was even more shocked when I took it home with me.

I’m not selling these phones and I don’t work for a cell phone company or Microsoft (yetWinking smile), but if a guy can’t convince his wife to get one, we’ve got a problem.  Shoot, I even convinced her to marry me, but I can’t pawn a phone on her!

The Fix

Actually, Fixes.  It’s plural.  Here are the things that can right the course for this beauty of a ship:

  1. Figure out the content licensing and make music available in the marketplace. If it’s a ways out, for now you must, must clearly communicate what the issues are.  Customers would be happy to lobby any group that is blocking the process.
  2. Set up Zune Pass now, even at a lower cost and with limited content. Get buy in from the Canadian content providers to get them in the streaming mix be it independent radio stations, the CBC, CTV or the sports broadcasters. Flesh out the product and give Canadians the same level of product that’s available in other countries around the world.
  3. Give out some more free phones.  Future Shop wouldn’t even let me play with one of WP7 phones until I said I was surely going to buy one.  They wouldn’t take it out of the box.  This is wrong and bad and a poor purchase experience and bad, too.  Apple has kiosks setup to demo different models of the iPod/Pad/Phone/Thing and for WP7 I get to look at a cellophane wrapped box? Boo!
  4. Increase visibility.  Get storefront space. Encourage cell phone dealers to use and promote the phone.  Roger’s booth in our mall here had the iPhone 4 announcement posters up six weeks before the phone was launched.  There is still nothing in the mall about WP7.  Nada.

I am a software developer and though my previous experience has been on other platforms and technologies, right now I work exclusively on the MS stack.  I am going to MIX11 and am super pumped to see what the year ahead will bring us.

I’ve already come to terms with the fact that most of my concerns will not be addressed by the time the event rolls around, but you can be sure I’ll be sharing my thoughts with whomever will give me an audience.  Basically, it’s a conference where I’ll be hanging out with a ton of folks who’s phones are cooler than mine; sadly, we’ll have the same phone.

This is a phone that can really give customers a fresh experience with a unique level of integration with communication, search, maps, gaming and social networking.  I really hope that WP7 survives in Canada long enough to bear the fruit it is longing to produce.

Sunday, March 20, 2011

jQuery IntelliSense with ASP.NET MVC and the Razor View Engine

The Razor view engine in ASP.NET MVC3 brings great improvements to the readability of code in the view.  Unfortunately, some of what I’d previously lamented in missed productivity improvements has stuck around.

If you are working with Razor’s reimplementation of Master Pages – Layouts – then you will likely run into the same kind of limitations with IntelliSense that existed in previous ASP.NET editors: you simply don’t get IntelliSense for jQuery on your views when you include the script reference in your _Layout.cshtml.

Enabling IntelliSense

The only way to get those digits moving at the speed of computer-type-it-for-me is to add the script references to your view.  Because we don’t want the script written to the page twice – once through the viewstart/layout and once through the view – we simply use our old if(false) trick (see part way down) to get IntelliSense back online.

@if (false)
    <script src="../../Scripts/jquery-1.4.4.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-ui.min.js" type="text/javascript"></script>

Write the if block out and then drag and drop the files from your scripts folder in the Solution Explorer as an easy way to do this.  Once you’ve done this once, you can then put it in your Toolbox by highlighting the code and dragging it to the Toolbox window.  Here, I’m about to rename it to something more useful:


How This Could Be Fixed

To understand why it’s not working we have to look at what the IDE is aware of and what it does to figure out what styles/scripts are available in the editor.

When you’re on a view, Visual Studio doesn’t really know which layout will be used to render the view.  In some cases you may have many and you may be dynamically selecting it based on, for instance, the role of a logged in user.

However, we also know that the MVC Framework relies heavily on convention, and chances are that the default, most-used scenario with the ViewStart/_Layout.cshtml being used is likely the one that most folks will be dealing with.

So I would propose this: in the event that there is only one _Layout in the Views folder, assume that this is the one that will be used. Infer style sheet and script references from this file and enable IntelliSense based on the same.