3
Vote

Exception in WidgetAlternatesFactory in DesignerTools

description

Everytime the Admin/Themes pages is requested, an exception occurs in WidgetAlternatesFactory in the DesignerTools module:

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot implicitly convert type 'Orchard.Themes.Models.ThemeEntry' to 'Orchard.ContentManagement.ContentPart'

===========================================================

Stack:

"2012-11-21 18:53:32,083 [110] Orchard.DisplayManagement.Implementation.DefaultDisplayManager - RuntimeBinderException thrown from Action1 by System.Action1[[Orchard.DisplayManagement.Implementation.ShapeDisplayingContext, Orchard.Framework, Version=1.6.0.0, Culture=neutral, PublicKeyToken=null]]
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot implicitly convert type 'Orchard.Themes.Models.ThemeEntry' to 'Orchard.ContentManagement.ContentPart'
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(Action1 action)
at Orchard.InvokeExtensions.Invoke[TEvents](IEnumerable
1 events, Action`1 dispatch, ILogger logger)
"

The problem is this line:
ContentPart contentPart = displayedContext.Shape.ContentPart;

The Shape.ContentPart is of type ThemeEntry, and cannot be cast to ContentPart.

See screenshot for a full color experience.

file attachments

comments

sfmskywalker wrote Nov 22, 2012 at 2:05 AM

Replacing the troublesome line with:

var contentPart = displayedContext.Shape.ContentPart as ContentPart;

will fix the issue, although it may be a concern that the Themes module sets a ThemeEntry onto a ContentPart property.