2

Resolved

CustomFormPart exceptions after 1.7.1 upgrade

description

Hi there,

I have a small custom contact form in the footer of a site that I just upgraded from 1.6 to 1.7.1 and although the form still renders, and the email (via workflow now) still works, I keep getting the logs filling up with the following exception which I cannot track down the source of. I have this happen before, and ended up just creating the form from scratch to get rid of the exceptions, but I thought I better log a ticket since I have quite a few more sites I still need to put through the upgrade process:
2013-10-07 09:59:26,123 [5] Orchard.DisplayManagement.Implementation.DefaultDisplayManager - RuntimeBinderException thrown from Action`1 by System.Action`1[[Orchard.DisplayManagement.Implementation.ShapeDisplayingContext, Orchard.Framework, Version=1.7.1.0, Culture=neutral, PublicKeyToken=null]]
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot implicitly convert type 'Orchard.CustomForms.Models.CustomFormPart' to 'Orchard.ContentManagement.ContentItem'
   at CallSite.Target(Closure , CallSite , Object )
   at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
   at CallSite.Target(Closure , CallSite , Object )
   at Orchard.DesignerTools.Services.WidgetAlternatesFactory.<Displaying>b__5(ShapeDisplayingContext displayedContext)
   at Orchard.DisplayManagement.Implementation.DefaultDisplayManager.<>c__DisplayClassc.<Execute>b__5(Action`1 action) in d:\Builds\OrchardFull\src\Orchard\DisplayManagement\Implementation\DefaultDisplayManager.cs:line 78
   at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable`1 events, Action`1 dispatch, ILogger logger) in d:\Builds\OrchardFull\src\Orchard\InvokeExtensions.cs:line 17
Any pointers or help appreciated.
Thanks,
Rob

comments

jao28 wrote Oct 19, 2013 at 8:35 PM

Hi Rob,

I had experienced this also. It is a problem in Orchard.DesignerTools.Services.WidgetAlternatesFactory.cs. Here is a hack to fix this and hopefully there is an official way to fix it properly (likely right in Orchard.CustomForms but I couldn't find any). You can make the following code change (starting at line 14):
// EMS CHANGE - start
ContentItem contentItem = null;
try {
    contentItem = displayedContext.Shape.ContentItem;
}
catch {
    // Ignoring the exception as this is normally a result of the CustomFormWidget not setting the contentitem correctly in the 
    //  Orchard.DisplayManagement.Shapes.Composite TryGetMemberImpl _props 
    //  It sets it as a ContentPart
    //  Since I don't understand how that get's set, just ignoring the error
}
// Original
//ContentItem contentItem = displayedContext.Shape.ContentItem;
// EMS CHANGE - end
Hope this helps.

sebastienros wrote Oct 24, 2013 at 12:09 AM

Fixed in changeset fcae27240c8e0f902b40b74d83a7aec41e00856e