Getting this error when indexing in Episerver Find: "System.Reflection.AmbiguousMatchException: Ambiguous match found."
After spending some time trying to figure out why I get a lot of these errors when Find are indexing my site I feel I need to share the info on why it happened.
The error are can come if you for example have a override property in a base class but for me I did not have that so I could not figure out why this happened.
I managed to figure out what pages that was reporting the error and after a lot of commeting out properties I ended up with identifying the problem and that was this line of code:
public virtual string Item { get; set; }
I change the name to Object and all started to work so Item seem to be a name that Episerver are using somewhere but unlike for example PageName that will generate a warning in code, it works for everything BUT indexing in Episerver Find.....
This was when I added the property to a local block I got that error, when I reproduced it on Alloy and added it directly on the PageType I got this error instead:
For this line:
var page = contentLoader.Get<PageData>(contentLink);
I got this error:
[InvalidCastException: Specified cast is not valid.]
EPiServer.Core.PageData.get_Status() +60
EPiServer.DataAccess.Internal.ContentDB.AssignVersionStatus(IVersionable versionStatus, DbDataReader reader) +303
EPiServer.DataAccess.Internal.ContentLoadDB.LoadContentInternal(ContentReference contentLink, Int32 languageBranchId, DbDataReader reader) +588
EPiServer.DataAccess.Internal.<>c__DisplayClass2_0.<Load>b__0() +208
EPiServer.Data.Providers.Internal.<>c__DisplayClass28_0`1.<Execute>b__0() +59
EPiServer.Data.Providers.SqlTransientErrorsRetryPolicy.Execute(Func`1 method) +51
EPiServer.Data.Providers.Internal.SqlDatabaseExecutor.Execute(Func`1 action) +203
EPiServer.DataAccess.Internal.ContentLoadDB.Load(ContentReference contentLink, Int32 languageBranchID) +109
EPiServer.Core.Internal.DefaultContentProviderDatabase.Load(ContentReference contentLink, Int32 languageBranchID) +31
EPiServer.Core.Internal.DefaultContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector) +88
EPiServer.Core.<>c__DisplayClass115_0.<LoadContentFromCacheOrRepository>b__0() +85
EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThroughWithWait(IObjectInstanceCache cache, String cacheKey, Func`1 readValue, Func`2 evictionPolicy) +710
EPiServer.Framework.Cache.ObjectInstanceCacheExtensions.ReadThrough(IObjectInstanceCache cache, String key, Func`1 readValue, Func`2 evictionPolicy, ReadStrategy readStrategy) +87
EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector) +729
EPiServer.Core.Internal.ProviderPipelineImplementation.GetItem(ContentProvider provider, ContentReference contentLink, LoaderOptions loaderOptions) +247
EPiServer.Core.Internal.DefaultContentLoader.TryGet(ContentReference contentLink, LoaderOptions loaderOptions, T& content) +259
EPiServer.Core.Internal.DefaultContentLoader.Get(ContentReference contentLink, LoaderOptions loaderOptions) +73
EPiServer.Core.Internal.DefaultContentLoader.Get(ContentReference contentLink) +68
FindIndexBug.Helpers.UrlHelpers.PageLinkUrl(UrlHelper urlHelper, ContentReference contentLink) in C:\Temp\FindIndexBug\FindIndexBug\Helpers\UrlHelpers.cs:27
ASP._Page_Views_Shared_Blocks_TeaserBlock_cshtml.Execute() in c:\Temp\FindIndexBug\FindIndexBug\Views\Shared\Blocks\TeaserBlock.cshtml:6
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +105
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +90
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +256
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +107
EPiServer.Web.Mvc.ViewExtensions.Render(IView view, ViewEngineResult viewEngineResult, ViewContext context, TextWriter writer, T data) +454
EPiServer.Web.Mvc.Internal.DefaultMvcContentRenderer.HandleRenderTemplateWithViewEngine(HtmlHelper helper, IContentData contentData, TemplateModel templateModel) +392
EPiServer.Web.Mvc.Internal.DefaultMvcContentRenderer.Render(HtmlHelper helper, PartialRequest partialRequestHandler, IContentData contentData, TemplateModel templateModel) +88
EPiServer.Web.Mvc.MvcContentRenderer.Render(HtmlHelper helper, PartialRequest partialRequestHandler, IContentData contentData, TemplateModel templateModel) +39
FindIndexBug.Business.Rendering.ErrorHandlingContentRenderer.Render(HtmlHelper helper, PartialRequest partialRequestHandler, IContentData contentData, TemplateModel templateModel) in C:\Temp\FindIndexBug\FindIndexBug\Business\Rendering\ErrorHandlingContentRenderer.cs:37
EPiServer.Web.Mvc.Html.IContentDataExtensions.RenderContentData(HtmlHelper html, IContentData contentData, Boolean isContentInContentArea, TemplateModel templateModel, IContentRenderer contentRenderer) +469
EPiServer.Web.Mvc.Html.ContentAreaRenderer.RenderContentAreaItem(HtmlHelper htmlHelper, ContentAreaItem contentAreaItem, String templateTag, String htmlTag, String cssClass) +934
EPiServer.Web.Mvc.Html.ContentAreaRenderer.RenderContentAreaItems(HtmlHelper htmlHelper, IEnumerable`1 contentAreaItems) +119
EPiServer.Web.Mvc.Html.ContentAreaRenderer.Render(HtmlHelper htmlHelper, ContentArea contentArea) +265
EPiServer.Web.Mvc.Html.ContentAreaExtensions.RenderContentArea(HtmlHelper htmlHelper, ContentArea contentArea) +50
ASP.util_views_shared_displaytemplates_contentarea_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in C:\Temp\FindIndexBug\FindIndexBug\Util\Views\Shared\DisplayTemplates\ContentArea.ascx:4
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +103
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +9
System.Web.UI.Control.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +129
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +287
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +27
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +197
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +9
System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +53
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +129
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +287
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +27
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5640
I changed it and instead added the property into a local block (that I had in the real solution) and then the site loaded but I get the Ambiguous match when indexing.
So, do not create properties with the name Item if you like to use Episerver!
Update on this:
Episerver has submitted it as a bug and hopefully it will be fixed soon, will update with a comment when it has been solved
I'm getting problems without having Find installed on a site. You can't save a page that contains a property named "Item" in the UI. The same thing when creating an integration test, CMS Core will not save a page that contains a property named "Item". Are you sure the problem occured because of Find? I don't see Find anywhere in the callstack.
@Jonas. No, when submitting the bug report I noticed that it was not problem with find (see the update in the post with the long error message).
The reason I thought it was with Find from the beginning was that when I had the property inside a local block everything worked except when serilizing the object.