Try our conversational search powered by Generative AI!

TypeMismatchException When Using SpecializedProperties.LinkItem

Vote:
 

I tried to create a LinkItem property in a block, but run into an error on initialization which seems only happen when the property type is not valid.

I am not sure if this exception is expected because I found an article: Backing type for LinkItem?. And it seems that the LinkItem was not working at that time.

However I am using the latest v8.11.0, so I just want to check out if this is still normal in this version and see if there is anything wrong with my Epi instance.

Here is the error shown in browser:

Server Error in '/' Application.

Type 'EPiServer.SpecializedProperties.LinkItem' could not be mapped to a PropertyDefinitionType

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: EPiServer.Core.TypeMismatchException: Type 'EPiServer.SpecializedProperties.LinkItem' could not be mapped to a PropertyDefinitionType

Source Error: 


[No relevant source lines]

Source File: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\fdc7017f\5b127880\App_global.asax.0.cs    Line: 0 

Stack Trace: 

[TypeMismatchException: Type 'EPiServer.SpecializedProperties.LinkItem' could not be mapped to a PropertyDefinitionType] EPiServer.DataAbstraction.RuntimeModel.PropertyDefinitionSynchronizer.ResolveType(PropertyDefinitionModel model) +438 EPiServer.DataAbstraction.RuntimeModel.PropertyDefinitionSynchronizer.CreatePropertyDefinition(PropertyDefinitionModel model, Int32 contentTypeID) +270 EPiServer.DataAbstraction.RuntimeModel.ContentTypeModelRegister.CommitProperties(Boolean deleteUnusedTypes) +407 EPiServer.DataAbstraction.RuntimeModel.ContentTypeModelScanner.Sync(Boolean commitChanges) +302 EPiServer.Initialization.ModelSyncInitialization.Initialize(InitializationEngine context) +569 EPiServer.Framework.Initialization.ModuleNode.Execute(Action a, String key) +64 EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +314 [InitializationException: Initialize action failed for Initialize on class EPiServer.Initialization.ModelSyncInitialization, EPiServer, Version=8.11.0.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7] EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +855 EPiServer.Framework.Initialization.InitializationEngine.Initialize(HostType hostType) +168 EPiServer.Framework.Initialization.InitializationModule.Initialize(HostType hostType) +935 EPiServer.Framework.Initialization.InitializationModule.FrameworkInitialization(HostType hostType) +104 EPiServer.Global..ctor() +110 [TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +159 System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +256 System.Activator.CreateInstance(Type type, Boolean nonPublic) +127 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +14297981 System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +198 System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +28 System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +83 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +312 System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475 [HttpException (0x80004005): Exception has been thrown by the target of an invocation.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12618692 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12458309
#133745
Sep 10, 2015 0:14
Vote:
 

Ethan,

This exception is indeed expected as there is currently no built-in property type for LinkItem.

#133747
Sep 10, 2015 1:37
Vote:
 

Hi Ethan,

There is no built in property  type for link item, however you can create the LinkItem collection and map only one item.

[Display(GroupName = GroupNames.Default, Order = 5, Name = "Quick Links", Description = "Quick Links")]
[CultureSpecific]
public virtual LinkItemCollection QuickLinks { get; set; }

Regards

Venkata Phani kumar R

#133752
Sep 10, 2015 5:38
Vote:
 

Thanks henriknystrom & Venkata,

These are really helpful, it calms my mind that this is not a potential problem. And I am acutally using the solution Venkata suggested, who doesn't like more buttons.

#133811
Sep 10, 2015 15:51
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.