Sean Holmesby

.NET and Sitecore Developer


Safe Dependency Injection for MVC and WebApi within Sitecore

This post describes how we’ve considered approaching dependency injection with Sitecore at Hedgehog Development.
Many people have posted about dependency injection in Sitecore before, and each has had their own twist.

We’ve noticed that sometimes Sitecore controllers are failing to be resolved when there is a custom Dependency Resolver added.
The problem, as described in Mickey’s first post, is that MVC only allows for one DependencyResolver. So the moment you set your own Dependency Resolver, whatever was set there before (like whatever Sitecore set as the Dependency Resolver) will no longer work.
Because of this, Sitecore’s registered types will no longer get resolved, and you might see the following errors in the logs when you try to access one of the out-of-the-box Sitecore applications.

Exception: Sitecore.Mvc.Diagnostics.ControllerCreationException
Message: Could not create controller: 'Settings'.
The current route url is: 'api/sitecore/{controller}/{action}'. 
Source: Sitecore.Mvc
   at Sitecore.Mvc.Controllers.SitecoreControllerFactory.CreateController(RequestContext requestContext, String controllerName)

Message: No component for supporting the service Sitecore.Controllers.SettingsController was found

I spoke to Charlie Turano about this, and our solution was to create a ChainedMvcResolver, which will set a ‘Fallback Resolver’ to whatever the resolver was before we came along and set ours.
Read More


Parsing a Delimited CSV File in Coveo

I was trying to find a way to take a single CSV file containing addresses, and parse each address into it’s own document.
The file had an address on every line, and was delimited with a ‘|’.


After posting on the forums about getting this to work with the File Connector, I was told that the Database Connector was better suited for this.

To set this up there were a couple of moving pieces, so I thought I’d detail them in this blog post.
Read More


The Truth About Sitecore Upgrades

This blog post gives some insight from what I’ve learnt about the Sitecore Upgrade process, and my beliefs about how you should approach an upgrade. Many people have their own opinions on upgrades, and many have voiced them, either through user groups, blog posts, or forum replies.
While I agree with some, and disagree with others, we’re all still learning…. so nothing should be taken as gospel from anyone…
The posts (including this one) are opinions, mainly based off the author’s own experiences… and so, if there are things here that I’ve missed in this post, or something you disagree with, please let me know in the comments.

At one stage or another, every client will want to upgrade their Sitecore instance.
This may be for bug fixes, or for some of the new features that come with the latest versions of Sitecore. And with the plethora of new marketing features in Sitecore 8, the push to be up-to-date has never been greater.

At Hedgehog Development, we’ve worked on numerous Sitecore upgrades over the years.
Every one of them we’ve learned something new. No two upgrades have been the same, and some have been far more complicated than others. We’ve even written custom applications that allow an upgrade to take place over a couple of weeks, to allow for full testing and a slow, controlled roll-out of new features.
With this experience, we’ve learnt the steps involved in the upgrade, and the importance of all the intricate processes that occur during the upgrade.
Read More


Debugging a custom Coveo conversion script

This post details the way I figured out how to debug a Coveo Pre or Post Converter written in .NET.
This blog post comes off the back of a question I asked on the Coveo Answers website.
Disclaimer: I am just starting to learn the inner workings of Coveo, and I could not find any documentation on exactly how to do this. If anyone has any other way of debugging, please let me know in the comments, but hopefully this can help anyone who was running into the same issues that I did.

Firstly, I am running Coveo Enterprise Search 7. This may change in future versions of CES, so be aware that this is how I managed to get it to work at the time of writing this post.

Setting up the project

  • Set up a C# class library project in Visual Studio.
  • Change the Target Framework of the project to .NET Framework 3.5.
    • Right click on the project
    • Select Properties
    • On the Application tab, select .NET Framework 3.5 from the Target Framework drop down.
  • Add a class for your conversion script. An example of one is below.
    using System;
    using Coveo.CES.ConversionScriptLoader;
    using Coveo.CES.ConversionScriptLoader.Interops.x64;
    namespace SampleCustomConverter {
        public class MySamplePostConverter : CustomConverter {
            public override void RunPostConverter(IPostConversion p_PostConversion, IDocumentInfo p_DocumentInfo) {
                p_PostConversion.Trace("Hello from my .NET post converter: " + p_DocumentInfo.URI, SeverityEnumeration.SeverityNormal);
  • Build the project in a Debug configuration.

Setting up the conversion script

When you go to add a post conversion script you are required to enter the Script File path and the Type Name.

  • In the Script File field, enter the full path of the DLL produced by the project.
    • i.e C:\MyProjects\SampleCustomConverter\bin\Debug\SampleCustomConverter.dll
  • In the Type Name field, enter the fully qualified type name of your class.
    • In [namespace].[class name] format
    • i.e SampleCustomConverter.MySamplePostConverter
  • Save the conversion script and apply it as you normally would.

Attaching the debugger

Back in Visual Studio, attach the debugger to the CESConverter7.exe process.

  • Select Debug -> Attach to Process
  • Change to ‘Managed (v3.5, v3.0, v2.0) code’
    • In the ‘Attach To:’ field, click ‘Select’
    • Select ‘Debug these code types’
    • Ensure you have ‘Managed (v3.5, v3.0, v2.0) code’ checked
  • Select the CESConverter7.exe process.
    • If the process doesn’t show up, you may have to start and stop a rebuild of the indexes in the CES Admin Tool.
  • Click ‘Attach’

Rebuild the source in the CES Admin Tool where you’ve setup your conversion script.
You should now see your breakpoints load, and get hit during the indexing of content.

For information about Pre or Post Conversion scripts, see the following:-


You, Me, and the Sitecore Community

Two nights ago I attended yet another fantastic session on Sitecore 8 at the Philadelphia Sitecore User Group.
The room was packed, the content was awesome, and the discussion was fantastic.
Yet it wasn’t the impressive talk that most impressed me about this meetup…

The event had me looking around the room, seeing both new and familiar faces, knowing that every person in the room was someone who I could chat to, get along with, and enjoy the company of.
This wasn’t just my awesome Hedgehog colleagues, or my fantastic team at Comcast… but absolutely every person in the room.

You see, this particular meetup is one of many that I have recently attended. It’s been a very Sitecorey month, from the New England Sitecore User Group at Genuine Interactive earlier in March, to the Sitecore and .NET based CMS Discussion event at NorthPoint Digital, to the online Sitecore Virtual User Group run by Hedgehog. At each of these events, the discussions, while insightful and entertaining, have taken a back seat to the sheer awesomeness of people in attendance.

In Boston, I got to catch up with some old friends, Tim Braga and Mark Stiles. I discussed some upgrade intricacies with other Sitecore enthusiasts, and learned even more about the xDB from Sitecore’s Justin West.
Afterwards we kicked on at the local bar for a couple of beers. We found ourselves not only discussing general development, but also life, family, and the ways of the world.
Mark and I wandered the streets afterwards, continuing the discussion. That guy has the greatest sense of humor out of anyone I’ve ever met. Just check out his latest blog post to see what I mean, and even catch his subtle jokes with the tool tips on each of the links throughout the post.
What a character!

At the NorthPoint meetup, again we had some more fantastic discussion around Sitecore… but the greatest part of the night was heading to the bar afterwards. I got to spend time with my close friend, former colleague and fellow Aussie-in-NYC, Julian Gilchrist. Again, the world of Sitecore development brought us together many years ago, but it’s the running in the park, shooting hoops, and a common strange accent that have us even closer now than ever.
Catching up with Jules is always a blast, but also hanging out with some other NorthPoint and Karbyn guys provided some awesome entertainment (and insight into many beers I’d never heard of before).

Mike Shaw still runs the Sitecore Virtual User Group, and while he’s moved to Hedgehog’s Charlotte office, we still chat daily about general stuff. I’ll never forget (or remember?) our nights out in Atlanta, or standing in the freezing cold at a Stadium Series Rangers game at Yankee Stadium.

These friendships are what have come from this awesome Sitecore community. Most people I have grown to know and appreciate here have originally come from a Twitter follow, an SDN post, or user group meetup.
The people in the Sitecore community share a special bond, that even when actually meeting someone for the first time, you feel like you’ve known them forever. That was the feeling I had at the symposium, and continue to have at these meetups.

The recent Active Commerce training we did with other Sitecore MVPs highlighted this, and showed how comfortable we are joking around with each other, even without having ever met.

But it’s not just that…

Nick Wesselman and I chatted like old mates when we first met face-to-face in Atlanta….
Mike Edwards, Jens Mikkelson and I wandered the streets of New York City together after only seeing each other for the first time a couple of days earlier.
Pieter Brinkman and Marissa Dresnek recorded selfie videos for me to place in the Sitecore Selfie music video… before we had ever met!
I’m still yet to formally meet the likes of Mike Robbins, Robbert Hock and Martina Welander, yet the years of helping each other out on Twitter have brought about a closeness that we also share with the rest of the community.

Mike Reynolds and I had planned to talk together at the 2014 symposium before we had ever actually met face-to-face. We now sporadically call each other to see what’s up.
Sure, we discuss Sitecore-related stuff from time to time, but we also chat about our weekends, our past, and our future.
Mike’s even helped me through some homesickness I had a little while back, and I cannot thank him enough for this.

This is the sort thing the Sitecore community brings.
It’s a constantly growing group, where everyone is welcome, and many new friends are continually being made.

The sharing of knowledge and willingness to help each other is one thing… but the mutual respect and care we have for each other is really what makes this group a fantastic bunch of people.

A common interest of a technology introduced us to one another, but the special bond of the community is something that will last forever.


Serialization Exception in the Sitecore 8 Experience Explorer

I recently received a serialization exception when attempting trigger a Campaign within the new Experience Explorer feature in Sitecore 8, using the LaunchSitecore demo site.

Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''.

[SerializationException: Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''. ]
ReadArrayOfKeyValueOfstringstringFromJson(XmlReaderDelegator , XmlObjectSerializerReadContextComplexJson , XmlDictionaryString , XmlDictionaryString , CollectionDataContract ) +885
System.Runtime.Serialization.Json.JsonCollectionDataContract.ReadJsonValueCore(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context) +154
System.Runtime.Serialization.Json.JsonDataContract.ReadJsonValue(XmlReaderDelegator jsonReader, XmlObjectSerializerReadContextComplexJson context) +61
System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract& dataContract) +210
System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns) +69
System.Runtime.Serialization.Json.DataContractJsonSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName) +177
System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver) +628
System.Runtime.Serialization.Json.DataContractJsonSerializer.ReadObject(XmlDictionaryReader reader) +73
Sitecore.Common.Serializer.Deserialize(String data, Type resultType) +541
Sitecore.Common.Serializer.Deserialize(String data) +89
Sitecore.SecurityModel.UserRuntimeSettings.DeserializeInnerDictionary(UserRuntimeSettings data, String dictionaryKey) +259
Sitecore.SecurityModel.UserRuntimeSettings.Deserialize(String data) +198
Sitecore.Security.Accounts.User.get_RuntimeSettings() +333

I also found the same issue when running my LaunchSitecoreTDS code base on a fresh instance…

Debugging this was difficult, as no exceptions were popping up in Visual Studio, and nothing useful was being written to the logs other that this exception.
Read More


Images not Resizing in Sitecore 7.5, Sitecore 8.0

Sitecore 7.5 brings some changes to the way images are resized on the server, and it may mean that you’ll find some images on your site aren’t being resized after upgrading. These changes are intentional, and provide better security for media requests, but depending on your past implementations…you may see this issue on your site.

Sitecore has always been able to resize images on the server by passing parameters to the image rendering controls, <sc:image> and <sc:FieldRenderer>.

In the past, the resulting image URL of this was the normal image path with a query string appended showing the parameters.
i.e http://mywebsite/~/media/System/Simulator Backgrounds/Android Phone.ashx?w=50

01 - Motorolla Full(trimmed for display here)

Shinks down to this….

02 - Motorolla Small(resized)

From Sitecore 7.5 onwards, if you attempt to load an image URL directly (by just appending a query string like the one above), the image will not be resized, and the full image will be shown.

Read More


Presentation Details Changes in Sitecore 8 – How Renderings are Stored with Versioned Layouts

Sitecore 8 has changed the way renderings on a page are stored on an item. A page’s full presentation can now be updated (hopefully through the Experience Editor) for an individual version…meaning those changes can go through workflow to be approved. It also means layout changes can be rolled back to previous versions easily.

Note: Screenshots and investigation for this post has been done using the Sitecore 8 Technical Preview handed to Sitecore MVPs. The final result may change for the initial release of Sitecore 8.

Read More


CopySauce, a file Copying Utility for Sitecore Development

A while ago a good friend of mine, Dave Nicolson, created a utility that assists front-end developers with Sitecore development. The tool watches changes to front-end files in your Source directory, and copies them over to your Website directory….saving the need for a full Visual Studio build, and thus, no App Pool recycle.

Download CopySauce here.

Note: Basic documentation is included in the download.

CopySauce was branded by Igloo (now Authentic Entertainment), and my original post of the utility can be found here.

Read More


Fixing Visual Studio IntelliSense in Sitecore MVC Views

IntelliSense in Visual Studio is a fantastic auto-complete feature that greatly improves your Sitecore development, however I’ve occasionally seen this not working in my MVC solutions.

01 - HTML Sitecore Helper not working

In particular, I was seeing the following error highlighted around any calls to the @Html.Sitecore() helper:-

‘System.Web.Mvc.HtmlHelper<Model>’ does not contain a definition for ‘Sitecore’ and no extension method ‘Sitecore’ accepting first argument of type ‘System.Web.Mvc.HtmlHelper<Model> could be found.’

This would mean that I could not get auto-complete on the @Html.Sitecore() helper, nor would I get auto-complete for my properties on my Glass Models.

Read More