Sitecore 10.3.1 config file includes alwaysExcludeVirtualFolder setting for media urls

Sitecore 10.3.1 released yesterday. I published my Visual Studio project with Sitecore 10.3.0 nuget package onto the new Sitecore 10.3.1 instance, I received a YSOD not understood by google search. 

The reason for the YSOD is: the Sitecore 10.3.1 Sitecore.config has a new alwaysExcludeVirtualFolder setting for urlBuilder used across assemblies (mainly Sitecore.Kernel.dll) and during publish I had overwritten the new DLLs with my old 10.3.0 DLLs that didn't understand the new setting. So, I put back the 10.3.1 bin DLLs from the setup files. Also, ensured to set Copy Local to false for my VS project Sitecore DLLs.


10.3.1 Sitecore.config:


So, if you are in my situation ensure that the new instance DLLs are NOT overwritten by the old DLLs or better update to Sitecore 10.3.1 nuget:




YSOD:

Server Error in '/' Application.

Could not find property 'alwaysExcludeVirtualFolder' on object of type: Sitecore.Links.UrlBuilders.DefaultItemUrlBuilderOptions

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.InvalidOperationException: Could not find property 'alwaysExcludeVirtualFolder' on object of type: Sitecore.Links.UrlBuilders.DefaultItemUrlBuilderOptions

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:

[InvalidOperationException: Could not find property 'alwaysExcludeVirtualFolder' on object of type: Sitecore.Links.UrlBuilders.DefaultItemUrlBuilderOptions]
   Sitecore.Configuration.DefaultFactory.AssignProperties(Object obj, Object[] properties) +2356
   Sitecore.Configuration.DefaultFactory.AssignProperties(XmlNode configNode, String[] parameters, Object obj, Boolean assert, Boolean deferred, IFactoryHelper helper) +641
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +326
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert) +72
   Sitecore.Configuration.DefaultFactory.GetConstructorParameters(XmlNode configNode, String[] parameters, Boolean assert) +161
   Sitecore.Configuration.DefaultFactory.CreateFromTypeName(XmlNode configNode, String[] parameters, Boolean assert) +114
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +163
   Sitecore.Configuration.DefaultFactory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert) +72
   Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, String[] parameters, Boolean assert) +703
   Sitecore.Links.LinkProvider.Initialize(String name, NameValueCollection config) +105
   Sitecore.Configuration.DefaultFactory.GetProviders(List`1 nodes) +596
   Sitecore.Configuration.DefaultFactory.GetProviders(String rootPath, TProvider& defaultProvider) +323
   Sitecore.Configuration.ProviderHelper`2.ReadProviders() +75
   Sitecore.Configuration.ProviderHelper`2.get_Provider() +116
   Sitecore.Links.DefaultLinkManager.ParseRequestUrl(HttpRequest request) +42
   Sitecore.Web.RequestUrl.Parse(HttpRequestBase request) +123
   Sitecore.Pipelines.HttpRequest.HttpRequestArgs.Initialize() +31
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +118
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists) +236
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
   Sitecore.Web.RequestEventsHandler.OnBeginRequest(HttpContextBase context) +166
   Sitecore.Nexus.Web.HttpModule.HttpApplication_BeginRequest(Object sender, EventArgs e) +121
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +218
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +182
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +94


********************************************************************

The following was another YSOD that was thrown due to the reason my Visual Studio web project was pointing to Microsoft.Web.Infrastructure version 2.0.1 while Sitecore 10.3.x expects Microsoft.Web.Infrastructure 1.0.0 so, either set your Visual Studio project dll reference to Do not copy or downgrade to 1.0.0.

YSOD - 2:

Server Error in '/' Application.

Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

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.IO.FileLoadException: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

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.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' could not be loaded.

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Stack Trace:

[FileLoadException: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   System.Web.WebPages.PreApplicationStartCode.Start() +0
   System.Web.Mvc.PreApplicationStartCode.Start() +39

[InvalidOperationException: The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +919
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +169
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +172
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +854

[HttpException (0x80004005): The pre-application start initialization method Start on type System.Web.Mvc.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040).]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +719

Comments