Why Display method is generating and trying to insert an IShapeProxyxxxxxxx in a dictionary expecting my model class

Topics: Customizing Orchard, Troubleshooting
Dec 13, 2012 at 3:17 PM

Trying to create certainly the most trivial module: a new Field....working at 80% but I get an exception when trying to simply display the field.

Here is my method in the Field driver class:

        protected override DriverResult Display(
            ContentPart part, Fields.DecoratorField field,
            string displayType, dynamic shapeHelper) {

            var settings = field.PartFieldDefinition.Settings.GetModel<DecoratorFieldSettings>();
            var viewModel = new DecoratorFieldViewModel
                Name = field.Name,
                Settings = settings

            return ContentShape("Fields_Contrib_Decorator", 
                    () => shapeHelper.Fields_Contrib_Decorator(Model: viewModel)

and my View\Fields\Contrib.Decorator.cshtml

@model Contrib.DecoratorField.ViewModels.DecoratorFieldViewModel
@using Contrib.DecoratorField.Settings;

   @T("Mode")<br />

I get an exception in ShapeTemplateBindingStrategy.Render which complain that code is trying to insert an IShapeProxyxxxxxxx in a dictionary requesting Contrib.DecoratorField.ViewModels.DecoratorFieldViewModel objects ????

            var result = htmlHelper.Partial(harvestShapeInfo.TemplateVirtualPath, displayContext.Value);

when I look in TemplateVirtualPath I have a correct info, the metadata is also correctly filled with the corresponding placement info, only problem is the displayContext.Value which contains a Proxyxxxxxx ????


Dec 13, 2012 at 3:56 PM

partially solved with @Model.Model but still not understood, seems that some CastelInterceptor and ClayShape behavior are involved here ????

Still don't understand why in some case I get directly my class and in someother situation I get this IShapeProxy ?

Is there somewhere something describing 'simply' how these components are used ? 

Dec 13, 2012 at 4:33 PM
shapeHelper.Fields_Contrib_Decorator(Model: viewModel)



In the second case you get your model "directly", in the first case the model is the thing consisting of "Model: viewModel", therefore you need to have Model.Model.

Dec 14, 2012 at 10:22 AM

@JLedel sorry but using second case I still get an IShapeProxy ??