I am trying to add a custom StandardValues provider to a Sitecore 8.1 site (8.1.0 rev 160519) and I am not having a good time.

To do this I reflected the standard Sitecore.Data.StandardValuesProvider in Sitecore.Kernel, copied all the codez and made the change I want. It compiles, so I assume it'll work :D

btw I am modifying the behaviour of private SafeDictionary<ID, string> GetStandardValues(Item item), for reasons

I attempt to wire up the patch thusly: -

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
        <add name="sitecore">
          <patch:attribute name="type">[REDACTED].Web.Sitecore.Providers.[REDACTED]StandardValuesProvider, [REDACTED].Web</patch:attribute>

But although my patch looks like it's worked in /showconfig.aspx, the site itself doesn't load: -

Server Error in '/' Application.

Unexpected provider type: 


Expected: Sitecore.Data.StandardValuesProvider

Kind of like.. it doesn't want to see another kind of provider besides the default one ?

Has anyone tried to do this and succeeded ?

  • Are you missing some Interface implementations? Will it work if you inherit the default? – Kasper Gadensgaard Apr 11 '17 at 6:46
  • There's no interface to inherit; my class inherits from the base System.Configuration.Provider.ProviderBase in the same way the StandardValuesProvider does, and I've literally copied all the code from StandardValuesProvider, pasted it in and changed the implementation of one method. I'm sure it's something I'm doing wrong patching the config, but I'm puzzled as to what (it all looks pretty basic). Thx for suggestions though :) – sh1rts Apr 11 '17 at 7:02
  • 3
    Have you tried inheriting Sitecore.Data.StandardValuesProvider instead? – Kasper Gadensgaard Apr 11 '17 at 7:03

As Kasper Gadensgaard mentioned in the comments, the StandardValuesManager requires a provider inherited from the StandardValuesProvider class:

public static class StandardValuesManager
    private static readonly ProviderHelper<StandardValuesProvider, StandardValuesProviderCollection> _helper = 
        new ProviderHelper<StandardValuesProvider, StandardValuesProviderCollection>("standardValues");
  • Had to copy a bunch of private methods from the StandardValuesManager into my subclass (urgh), but this worked - thanks :^) – sh1rts Apr 12 '17 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.