Digital Transformation

Sitecore 6.6 Technical Preview MVC Test Lab Bug Fix

Last week I wrote a blog post about a fix for the bug you will get in Sitecore 6.6 rev 120622 when you try utilizing DMS Personalization on an MVC site.  If you are interested in using the Sitecore Test Lab, which allows Content Editors to create A/B and Multivariate Tests on their content in the Technical Preview of Sitecore 6.6, you will receive a very similar error.  In fact, you’ll get the same error, just generated from a different class / method. Again, the actual error is “Method ‘ToString’ in type ‘Sitecore.Mvc.Analytics.Presentation.EmptyRenderer’ from assembly ‘Sitecore.Mvc.Analytics, Version=, Culture=neutral, PublicKeyToken=null’ does not have an implementation.

To fix the Test Lab error, you simply need to add the following class to the file I had you create in the last post:

public class CustomSelectVariation : SelectVariation
protected override void ApplyVariation(CustomizeRenderingArgs args, ComponentTestContext context)
Assert.ArgumentNotNull((object)args, "args");
Assert.ArgumentNotNull((object)context, "context");
ComponentTestRunner componentTestRunner = new ComponentTestRunner();
catch (Exception ex)
Log.Warn(StringExtensions.FormatWith("Failed to execute MV testing on component with id \"{0}\". Item ID:\"{1}\"", (object)(ItemUtil.IsNull(context.Component.RenderingID) ? string.Empty : context.Component.RenderingID.ToString()), (object)(args.PageContext.Item != null ? args.PageContext.Item.ID.ToString() : string.Empty)), ex, (object)this);
RenderingReference reference = Enumerable.FirstOrDefault<RenderingReference>((IEnumerable<RenderingReference>)context.Components, (Func<RenderingReference, bool>)(c => c.UniqueId == context.Component.UniqueId));

if (reference == null)
args.Renderer = (Renderer)new MVCTestSite.Common.CustomEmptyRenderer();
this.ApplyChanges(args.Rendering, reference);

Similar to the last situation, we now have our code that will bypass the above error completely.  Our last step is to get our code to be called in the Sitecore pipeline so that it overrides the normal functions.  Again, we do that by making the following change to the file Sitecore.MvcAnalytics.config which is found in the App_Config/Include folder of our website.

Find and Replace the line:

<processor type="Sitecore.Mvc.Analytics.Pipelines.Response.CustomizeRendering.SelectVariation, Sitecore.Mvc.Analytics"/>


<processor type="MVCTestSite.Common.CustomSelectVariation, MVCTestSite"/>

(Where “MVCTestSite.Common” is the namespace you used for your above code, “CustomSelectVariation” is the classname of the class above, and “MVCTestSite” is the name of the DLL your site compiles into.)

Once that’s done, you should now be able to use the Sitecore Test Lab on your MVC site!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Jamie Stump

My name is Jamie Stump, and I am a Senior Sitecore Consultant at Perficient. I was honored to be named one of only 42 2013 Sitecore MVP’s worldwide. I specialize in Sitecore Architecture and Development and my broad Sitecore experience includes Sitecore installation, configuration and CEP development, including custom DMS implementations for clients. I have implemented Sitecore solutions for a number of industry verticals including manufacturing, healthcare, financial services, advertising and retail. In addition to architecting and implementing Sitecore sites and eCommerce solutions, I also work with other Microsoft Technologies, including the .NET platform and SQL Server. You can read through my older Sitecore related blog posts here and my newer ones here. I graduated with a Bachelor of Science in Information Systems Development from York College of PA. I am originally from the suburbs of Philadelphia, PA, and still reside there with my wife, son, English bulldog and 2 cats.

More from this Author

Follow Us