Sitecore 10.1.0 Helix Visual Studio Project Publish Issue - Could not find type: Sitecore.Mvc.ServicesConfigurator, Sitecore.Mvc []

 Error:

Server Error in '/' Application.

Could not find type: Sitecore.Mvc.ServicesConfigurator, Sitecore.Mvc [<configurator type="Sitecore.Mvc.ServicesConfigurator, Sitecore.Mvc" patch:source="Sitecore.Mvc.config" xmlns:patch="http://www.sitecore.net/xmlconfig/" />]

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.Configuration.ConfigurationException: Could not find type: Sitecore.Mvc.ServicesConfigurator, Sitecore.Mvc [<configurator type="Sitecore.Mvc.ServicesConfigurator, Sitecore.Mvc" patch:source="Sitecore.Mvc.config" xmlns:patch="http://www.sitecore.net/xmlconfig/" />]

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[ConfigurationException: Could not find type: Sitecore.Mvc.ServicesConfigurator, Sitecore.Mvc [<configurator type="Sitecore.Mvc.ServicesConfigurator, Sitecore.Mvc" patch:source="Sitecore.Mvc.config" xmlns:patch="http://www.sitecore.net/xmlconfig/" />]]
   Sitecore.DependencyInjection.<>c.<GetServicesConfigurators>b__2_0(XmlNode x) +261
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +241
   Sitecore.DependencyInjection.BaseServicesConfiguratorFactory.Configure(IServiceCollection serviceCollection) +193
   Sitecore.DependencyInjection.BaseServicesConfiguratorFactory.Configure(IServiceCollection serviceCollection) +171
   Sitecore.DependencyInjection.BaseServiceProviderBuilder.ConfigureServiceCollection() +142
   Sitecore.DependencyInjection.ServiceLocator.ConfigureServiceProvider() +225
   Sitecore.DependencyInjection.ServiceLocator.get_ServiceProvider() +513
   Sitecore.DependencyInjection.SitecorePerRequestScopeModule..ctor() +13

[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) +142
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +107
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1476
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +186
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +28
   System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +80
   System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +234
   System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1153
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +139
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +168
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +277
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +369

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



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

Cause:

The Sitecore.Mvc dll from my Visual Studio project had overwritten the dll in the bin folder. Also, they were both different versions. So, I did the following:

1. Replaced the bin dll with the original version, you can get the dll from the bin folder of the relevant Sitcore version scwdp zip!

2. Ensure that your project references has the same version as what is deployed in the bin folder and set copy local to false for the dll so that future publish doesn't unnecessarily overwrite the bin folder dll



3. Publish the project to cross-check there is no overwrite if copy local is set to false

Comments

Popular Posts