Getting casting error when running the indexing job

Petter Klang
Member since: 2008

When running the "EPiServer Find CMS Indexing Job" I keep getting errors now and then that it can't cast a NativeDirectory to a VersionningDirectory. What puzzles me with this error is that we aren't using any VPPs on this site. We are getting all documents and Images through ImageVault. And from my understandment the Indexing of files should be off by default so why would it even try to work on a file?

So.. Anyone got a tip on what property might be getting interpreted as a NativeDirectory?


2013-01-31 10:56:58,879 ERROR [43] EPiServer.Find.Cms.PageIndexer.ReIndex - An exception occured while indexing (Batch): Unable to cast object of type 'EPiServer.Web.Hosting.NativeDirectory' to type 'EPiServer.Web.Hosting.VersioningDirectory'..
System.InvalidCastException: Unable to cast object of type 'EPiServer.Web.Hosting.NativeDirectory' to type 'EPiServer.Web.Hosting.VersioningDirectory'.
at EPiServer.Find.Cms.PageDataExtensions.GetPageFiles(PageData page)
at EPiServer.Find.Cms.PageIndexer.Index(IEnumerable`1 pages, IndexOptions options)
at EPiServer.Find.Cms.PageIndexer.ReIndex(Action`1 statusAction, Func`1 isStopped)

#65517 Jan 31, 2013 11:13

    Are you sure that there isn't any code activating indexing of page files? Also, what version of the .NET API and CMS integration are you using? In the old days of Truffler page files indexing was active by default.

    #65519 Jan 31, 2013 12:24
  • Petter Klang
    Member since: 2008

    Can't find any code that would activate indexing of page files.

    We are running the version the one for CMS 6 R2.

    Did a run with PageIndexer.Instance.Conventions.DisablePageFilesIndexing(); added but still getting the same error.

    #65522 Jan 31, 2013 13:06
  • Petter Klang
    Member since: 2008

    Checking with Reflector it seems that IndexPageFiles would default to true. Where would the Index Object first get instantiated when running the indexing job?


    // Generated by .NET Reflector 
    namespace EPiServer.Find.Cms
    using System;
    using System.Runtime.CompilerServices;

    public class IndexOptions
    public IndexOptions()
    this.IndexRelations = true;
    this.FilterPages = true;
    this.IndexPageFiles = true;

    public bool FilterPages { get; set; }

    public bool IndexPageFiles { get; set; }

    public bool IndexRelations { get; set; }


    #65523 Edited, Jan 31, 2013 13:24


    This is a bug in the current versions (7.0.586.0 and of EPiServer.Find.CMS.dll when using the EPiServer.Web.Hosting.VirtualPathNativeProvider for serving PageFiles.

    This will be fixed in the next EPiServer Find update.


    #65526 Jan 31, 2013 14:09
  • Petter Klang
    Member since: 2008

    And for future reference. The workaround while waiting for a fix is to set your PageFile provider to use EPiServer.Web.Hosting.VirtualPathVersioningProvider. (Note this might not work if you already have files in your vpp)


    Thanks for the help Henrik!

    #65533 Jan 31, 2013 15:55