Attempted to access an element as a type incompatible with the array.

Intro:

I once had a strange error when trying acces sitecore Backend or Frontend. After roll back App_Config and bin folder the error still was there. If I check web.config I relized it was way smaller then usually in a Sitecore 8.
The error of "Attempted to access an element as a type incompatible with the array." was a web.config of a recently added feature. When building it with gulp I overrides teh web.confi inthe website root.

Solution:

In my recentrly added feature I set the web.config property "Build Action" to "None". That soled it for me.





Server Error in '/' Application.

Attempted to access an element as a type incompatible with the array.

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: System.ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.

Source Error:


Line 13:             };
Line 14: 
Line 15:             ViewEngines.Engines.Insert(0, engine);
Line 16: 
Line 17:             // StartPage lookups are done by WebPages. 

Source File: d:\Source\...\BE\src\Foundation\Dictionary\code\App_Start\RazorGeneratorMvcStart.cs    Line: 15

Stack Trace:


[ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.]
   System.Collections.Generic.List`1.Insert(Int32 index, T item) +64
   System.Web.Mvc.ViewEngineCollection.InsertItem(Int32 index, IViewEngine item) +36


[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +260
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +146
   WebActivatorEx.BaseActivationMethodAttribute.InvokeMethod() +83
   WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) +699
   WebActivatorEx.StartMethodCallingModule.Init(HttpApplication context) +124
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +583
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +169
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +396
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +333

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +124
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +700



Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2103.2

Comments