I am testing testing DXA .NET 1.2, when rendering a Component with a MediaItem, I get the exception:
Cannot create an abstract class the modelType. the value is:
modelType {Name = "MediaItem" FullName = "Sdl.Web.Common.Models.MediaItem"} System.Type {System.RuntimeType}
My site.log
shows the following error:
Sdl.Web.Common.DxaException: Unable to map field 'media' to property of type 'Sdl.Web.Common.Models.MediaItem'.
code from dxa-web-application-dotnet/Sdl.Web.Tridion/Mapping/DefaultModelBuilder.cs
model = (ViewModel)Activator.CreateInstance(modelType);
FULL log:
015-12-04 18:39:39,553 [17] ERROR - Unable to map field 'media' to property of type 'Sdl.Web.Common.Models.MediaItem'.
Sdl.Web.Common.DxaException: Unable to map field 'media' to property of type 'Sdl.Web.Common.Models.MediaItem'. ---> System.MissingMethodException: Cannot create an abstract class.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.CreateViewModel(MappingData mappingData) in c:\Jenkins\workspace\DXA Dev CI Web App .NET\Sdl.Web.Tridion\Mapping\DefaultModelBuilder.cs:line 389
at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.BuildEntityModel(EntityModel& entityModel, IComponent component, Type baseModelType, Localization localization) in c:\Jenkins\workspace\DXA Dev CI Web App .NET\Sdl.Web.Tridion\Mapping\DefaultModelBuilder.cs:line 202
at Sdl.Web.Tridion.Mapping.ModelBuilderPipeline.CreateEntityModel(IComponent component, Type baseModelType, Localization localization) in c:\Jenkins\workspace\DXA Dev CI Web App .NET\Sdl.Web.Tridion\Mapping\ModelBuilderPipeline.cs:line 119
at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.MapComponent(IComponent component, Type modelType, Localization localization) in c:\Jenkins\workspace\DXA Dev CI Web App .NET\Sdl.Web.Tridion\Mapping\DefaultModelBuilder.cs:line 737
at Sdl.Web.Tridion.Mapping.DefaultModelBuilder.MapFieldValues(IField field, Type modelType, Boolean multival, MappingData mapData) in c:\Jenkins\workspace\DXA Dev CI Web App .NET\Sdl.Web.Tridion\Mapping\DefaultModelBuilder.cs:line 609
--- End of inner exception stack trace ---
at Sdl.Web.Mvc.Controllers.BaseController.EnrichModel(ViewModel model) in c:\Jenkins\workspace\DXA Dev CI Web App .NET\Sdl.Web.Mvc\Controllers\BaseController.cs:line 84
at Sdl.Web.Mvc.Controllers.EntityController.Entity(EntityModel entity, Int32 containerSize) in c:\Jenkins\workspace\DXA Dev CI Web App .NET\Sdl.Web.Mvc\Controllers\EntityController.cs:line 18
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass48.b__41()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.b__1c()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.b__1e(IAsyncResult asyncResult)