Sitecore 9.2 Helix ,How to use Assets, SitecoreExtension and Dependency Injection that exist in foundation layer of habitat - sitecore

I am beginner to development in sitecore using Helix Design Principle
i started with blank project and added one feature in feature layer and one layout in project layer as in this image and it works fine.
my issue when i tried to use asset module for styling purpose that exists in foundation layer of habitat to my project, it told me that it needs Dependency Injection and Sitecore Extension
and when i try to load DependenyInjection inside my project , and deploy it with gulpfile as in this image,the sitecore gave me that error
Server Error in '/' Application.
Could not load file or assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
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.FileNotFoundException: Could not load file or assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 187: try
Line 188: {
Line 189: return assembly.GetExportedTypes();
Line 190: }
Line 191: catch (NotSupportedException)
Source File: D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs Line: 189
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' 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:
[FileNotFoundException: Could not load file or assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
System.Reflection.RuntimeAssembly.GetExportedTypes(RuntimeAssembly assembly, ObjectHandleOnStack retTypes) +0
System.Reflection.RuntimeAssembly.GetExportedTypes() +32
Sitecore.Foundation.DependencyInjection.ServiceCollectionExtensions.GetExportedTypes(Assembly assembly) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs:189
[InvalidOperationException: Unable to load types from assembly Sitecore.XA.JSS.Foundation.Integration, Version=5.9.0.0, Culture=neutral, PublicKeyToken=null. Could not load file or assembly 'Sitecore.JavaScriptServices.AppServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.]
Sitecore.Foundation.DependencyInjection.ServiceCollectionExtensions.GetExportedTypes(Assembly assembly) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs:210
System.Linq.<SelectManyIterator>d__17`2.MoveNext() +265
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +287
System.Linq.WhereEnumerableIterator`1.MoveNext() +255
Sitecore.Foundation.DependencyInjection.ServiceCollectionExtensions.AddClassesWithServiceAttribute(IServiceCollection serviceCollection, Assembly[] assemblies) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs:39
Sitecore.Foundation.DependencyInjection.ServiceCollectionExtensions.AddClassesWithServiceAttribute(IServiceCollection serviceCollection, String[] assemblyFilters) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\ServiceCollectionExtensions.cs:27
Sitecore.Foundation.DependencyInjection.Infrastructure.MvcControllerServicesConfigurator.Configure(IServiceCollection serviceCollection) in D:\Ejada Files\NewsEjada - Copy - Copy\src\Foundation\DependencyInjection\code\Infrastructure\MvcControllerServicesConfigurator.cs:12
Sitecore.DependencyInjection.BaseServicesConfiguratorFactory.Configure(IServiceCollection serviceCollection) +171
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

First, take a look at this sitecore community question as it feels similar to your case.
Then, if not fixed :
Make sure you have added the sitecore nuget source (https://sitecore.myget.org/F/sc-packages/api/v3/index.json) in your visual studio using nuget package manager -> Package Sources.
Add this source to your nuget.config within your solution as well.
Make sure you don't have any of those following dependencies already installed with some other reference within your project
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.Mvc" Version="5.2.4" />
<PackageReference Include="Microsoft.AspNet.Razor" Version="3.2.4" />
<PackageReference Include="Microsoft.AspNet.WebPages" Version="3.2.4" />
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="1.0.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Net.Compilers" Version="1.3.2" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="System.ComponentModel" Version="4.0.1" />
<PackageReference Include="System.Diagnostics.Debug" Version="4.0.11" />
<PackageReference Include="System.Globalization" Version="4.0.11" />
<PackageReference Include="System.Linq" Version="4.1.0" />
<PackageReference Include="System.Linq.Expressions" Version="4.1.0" />
<PackageReference Include="System.Reflection" Version="4.1.0" />
<PackageReference Include="System.Resources.ResourceManager" Version="4.0.1" />
</ItemGroup>
From habitat project repos

Related

Could not load type 'Sitecore.LayoutService.ItemRendering.Factories.Interfaces.IRenderingFactory'

This issue started, while I installed Sitecore JavaScript Services Server for Sitecore 10.0.0 XP 15.0.1 rev. 201112 while my Sitecore is 10.2, Kindly please suggest or help me with respect to the issue.
Could not load type 'Sitecore.LayoutService.ItemRendering.Factories.Interfaces.IRenderingFactory' from assembly 'Sitecore.LayoutService, Version=6.1.0.0, Culture=neutral, PublicKeyToken=null'.
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.TypeLoadException: Could not load type 'Sitecore.LayoutService.ItemRendering.Factories.Interfaces.IRenderingFactory' from assembly 'Sitecore.LayoutService, Version=6.1.0.0, Culture=neutral, PublicKeyToken=null'.
Source Error:
The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:
Add a "Debug=true" directive at the top of the file that generated the error. Example:
or:
Add the following section to the configuration file of your application:
Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.
Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.
Stack trace:
[TypeLoadException: Could not load type 'Sitecore.LayoutService.ItemRendering.Factories.Interfaces.IRenderingFactory' from assembly 'Sitecore.LayoutService, Version=6.1.0.0, Culture=neutral, PublicKeyToken=null'.]
Sitecore.LayoutService.GraphQL.RegisterDependencies.Configure(IServiceCollection serviceCollection) +0
Sitecore.DependencyInjection.BaseServicesConfiguratorFactory.Configure(IServiceCollection serviceCollection) +171
Sitecore.DependencyInjection.BaseServicesConfiguratorFactory.Configure(IServiceCollection serviceCollection) +171
Sitecore.DependencyInjection.BaseServiceProviderBuilder.ConfigureServiceCollection() +142
Sitecore.DependencyInjection.ServiceLocator.ConfigureServiceProvider() +225
Sitecore.DependencyInjection.ServiceLocator.get_ServiceProvider() +513
Sitecore.Web.Application..cctor() +45
[TypeInitializationException: The type initializer for 'Sitecore.Web.Application' threw an exception.]
ASP.global_asax..ctor() +28
[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.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +182
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
Any suggestion is most appreciated, I am new to sitecore, and not able to find much information on the same, please guide me.

ML.Net model builder - Why do I get an SQL data error " Incorrect syntax near the keyword 'Open' "?

I am using ML.Net Model Builder version: 16.3.0.2056001 on Visual Studio 2019, using .Net 5.0.
Using Model Builder Wizard with a fresh template project, I select Add > Machine Learning > Connect to SQL Server, which is Tested successfully and the Table data loaded correctly into Preview.
When I then continue to the next screen and click Start Training, I get the following error:
Incorrect syntax near the keyword 'Open'
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at Microsoft.ML.Data.DatabaseLoader.Cursor.get_DataReader()
at Microsoft.ML.Data.DatabaseLoader.Cursor.MoveNextCore()
at Microsoft.ML.Data.RootCursorBase.MoveNext()
at Microsoft.ML.AutoML.DatasetDimensionsUtil.CountRows(IDataView data, UInt64 maxRows)
at Microsoft.ML.AutoML.ExperimentBase2.Execute(IDataView trainData, ColumnInformation columnInformation, IEstimator1 preFeaturizer, IProgress1 progressHandler) at Microsoft.ML.ModelBuilder.AutoMLService.Experiments.AutoMLExperiment3.<>c__DisplayClass21_0.b__5() in //src/Microsoft.ML.ModelBuilder.AutoMLService/Experiments/AutoMLExperiment.cs:line 80
at System.Threading.Tasks.Task1.InnerInvoke() at System.Threading.Tasks.Task.Execute() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.ML.ModelBuilder.AutoMLService.Experiments.AutoMLExperiment3.d__21.MoveNext() in //src/Microsoft.ML.ModelBuilder.AutoMLService/Experiments/AutoMLExperiment.cs:line 107
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.ML.ModelBuilder.AutoMLEngine.d__26.MoveNext() in /_/src/Microsoft.ML.ModelBuilder.AutoMLService/AutoMLEngineService/AutoMLEngine.cs:line 150
This is standard scaffold project and I've tried adding the following nuget packages to try and resolve this:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ML" Version="1.5.4" />
<PackageReference Include="Microsoft.ML.Experimental" Version="0.17.4" />
</ItemGroup>
</Project>
OK, I have solved the problem. I am using trading market data which includes a column for price called 'Open' and another for 'Close'. ML.Net did not like these column names. As soon as I have renamed them to OpenPrice and ClosePrice, the training is running fine :)

Constructor on type 'CommonController' not found issue in Simple Injector Sitecore 8.1 MVC

I have implemented Simple Injector in Sitecore 8.1 MVC glass mapper v4 project and using Controller rendering on MVC Layout.When I run the page getting following error:
Server Error in '/' Application.
Constructor on type 'GlassSimpleInjector.Controllers.CommonController' not found.
Description: An unhandled exception occurred.
Exception Details: System.MissingMethodException: Constructor on type 'GlassSimpleInjector.Controllers.CommonController' not found.
Source Error:
Line 13: <h1>#Html.Sitecore().Field("title")</h1>
Line 14: <div>
Line 15: #Html.Sitecore().Placeholder("main")
Line 16: </div>
Line 17: </body>
Source File: c:\inetpub\wwwroot\GlassSimpleInjector\Website\Views\Shared\MVC Layout.cshtml Line: 15
Stack Trace:
[MissingMethodException: Constructor on type 'GlassSimpleInjector.Controllers.CommonController' not found.]
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +14259449
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +200
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +28
Sitecore.Mvc.Helpers.TypeHelper.CreateObject(Type type, Object[] parameters) +43
Sitecore.Mvc.Controllers.SitecoreControllerFactory.CreateControllerInstance(RequestContext requestContext, String controllerName) +330
Sitecore.Mvc.Controllers.SitecoreControllerFactory.CreateController(RequestContext requestContext, String controllerName) +122
[ControllerCreationException: Could not create controller: ' GlassSimpleInjector.Controllers.CommonController,GlassSimpleInjector'.
The context item is: '/sitecore/content/Home'.
The current route url is: '{*pathInfo}'. This is the default Sitecore route which is set up in the 'InitializeRoutes' processor of the 'initialize' pipeline. ]
Sitecore.Mvc.Controllers.SitecoreControllerFactory.CreateController(RequestContext requestContext, String controllerName) +371
Sitecore.Mvc.Controllers.ControllerRunner.GetController() +24
Sitecore.Mvc.Controllers.ControllerRunner.Execute() +54
Sitecore.Mvc.Presentation.ControllerRenderer.Render(TextWriter writer) +131
Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args) +27
Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args) +62
(Object , Object[] ) +83
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +369
Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +202
Sitecore.Mvc.Pipelines.Response.RenderPlaceholder.PerformRendering.Render(String placeholderName, TextWriter writer, RenderPlaceholderArgs args) +192
(Object , Object[] ) +83
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +369
Sitecore.Mvc.Pipelines.PipelineService.RunPipeline(String pipelineName, TArgs args) +202
Sitecore.Mvc.Helpers.SitecoreHelper.Placeholder(String placeholderName) +323
ASP._Page_Views_Shared_MVC_Layout_cshtml.Execute() in c:\inetpub\wwwroot\GlassSimpleInjector\Website\Views\Shared\MVC Layout.cshtml:15
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +280
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +126
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +125
System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData) +147
Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer) +258
I have done almost all configuration but don't know what is missing.
Any suggestion.
I have implemented the solution from this link
Simple Injector
Update as on 11/24/2015
Just want to throw some light on structure
I have two MVC project:
GlassSimpleInjector.Global -->I did basic SimpleInjector implementation here and added SimpleInjector.cs class inside App_Start folder which contains common functionality and registered ISitecoreService and ISitecoreContext
GlassSimpleInjector --> I have added SimpleInjector.cs file inside App_Start where I have registered interface and classes only speicific to this project
SimpleInjector.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"
xmlns:set="http://www.sitecore.net/xmlconfig/set/">>
<sitecore>
<pipelines>
<initialize>
<processor type="Sitecore.Mvc.Pipelines.Loader.InitializeControllerFactory, Sitecore.Mvc"
set:type="GlassSimpleInjector.Global.Pipelines.DI.InitializeSimpleInjectorControllerFactory, GlassSimpleInjector.Global" />
</initialize>
</pipelines>
</sitecore>
</configuration>
Are you sure your controller factory is getting registered? According to the stack trace SimpleInjectorControllerFactory is not being invoked. Try checking the showConfig page to see if your processor is getting patched into the initialize pipeline correctly.
Update in response to comment from OP
The first block of code in Akshay's post is a Sitecore config patch file that needs to go in the /App_Config/Include folder. Note that you will need to put it in an additional subfolder or name the file so that it comes alphabetically after the Sitecore.Mvc.config in order for it to correctly patch the original processor. If you go to /sitecore/admin/showconfig.aspx in a browser, you can see the merged configuration. You should see your custom processor in the place of the original InitializeControllerFactory processor in the initialize pipeline. If it's not there, then your controller factory won't get registered.
Update
The problem is an extra right angle bracket in the config patch file.

Object reference not set to an instance of an object. in sitecore

I moved all of the sitecore data developed in our local environment to the Amazon Web Service's Server.
I attached database. setting IIS. and rewrote connection strings.
But it doesn't work. I saw error page like this when I access top page.
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.NullReferenceException: Object reference not set to an instance of an object.
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:
[NullReferenceException: Object reference not set to an instance of an object.]
Sitecore.Diagnostics.Log.Error(String message, Exception exception, Type ownerType) +246
Sitecore.Configuration.Factory.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +1064
Sitecore.Configuration.Factory.GetConfiguration() +331
Sitecore.Diagnostics.LoggerFactory..cctor() +58
[TypeInitializationException: The type initializer for 'Sitecore.Diagnostics.LoggerFactory' threw an exception.]
Sitecore.Diagnostics.LoggerFactory.GetLogger(Type type) +28
Sitecore.Diagnostics.Log.Error(String message, Exception exception, Type ownerType) +150
Sitecore.Configuration.Factory.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +1065
Sitecore.Configuration.Factory.GetConfiguration() +332
Sitecore.Configuration.Factory.GetConfigNode(String xpath, Boolean assert) +117
Sitecore.Resources.Media.UploadWatcher.InitializeIgnoreList() +182
[TypeInitializationException: The type initializer for 'Sitecore.Resources.Media.UploadWatcher' threw an exception.]
Sitecore.Resources.Media.UploadWatcher..ctor() +0
[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) +14407909
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.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +334
System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1262
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +133
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
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) +12601936
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12441597
Local environment
windows 7
SQL Server 2012 sp1
IIS 7.5
Sitecore version 7.2
AWS environment
Windows Server R2 Standard
SQL Server 2012 Express sp1
IIS 8.5
Sitecore version 7.2
I have tried all the way written in this page(tracking NullReferenceExceptions in sitecore)
but these techniques doesn't work in this case.
Please tell me how to do, if someone knows.
Thank you.
This gives away the cause of the exception:
Sitecore.Configuration.Factory.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +1064
Sitecore.Configuration.Factory.GetConfiguration() +331
You have an error in one of the config include files (/App_Config/Include)
There is probably some malformed XML in there somewhere.
Also make sure there are no *.Debug.config or *.Release.config files in there.

When does Sitecore run the initialize pipeline?

I have been peeking through the Sitecore.Kernel but can't seem to find the place where Sitecore runs the Initialize pipeline. Does it run on every page request or only once on application start? Can you point me to the exact place where the Run method is being called for this pipeline?
update
There reason I ended up asking this question is because I was tracing back, in Sitecore's code, the execution of the mvc.requestBegin pipeline. This is what I found:
the Initialize pipeline runs the InitializeRoutes processor...
Sitecore.Mvc.Pipelines.Loader.InitializeRoutes.Process(PipelineArgs args)
calls...
Sitecore.Mvc.Pipelines.Loader.InitializeRoutes.RegisterRoutes(RouteCollection routes, PipelineArgs args) calls...
Sitecore.Mvc.Pipelines.Loader.InitializeRoutes.SetRouteHandlers(RouteCollection routes, PipelineArgs args) creates new RouteHandlerWrapper objects
here things get a bit fuzzy...
Sitecore.Mvc.Routing.RouteHandlerWrapper.GetHttpHandler(RequestContext requestContext) returns (IHttpHandler) new RouteHttpHandler
and then, finally...
Sitecore.Mvc.Routing.RouteHttpHandler.ProcessRequest(HttpContext context) calls...
Sitecore.Mvc.Routing.RouteHttpHandler.BeginRequest() runs mvc.requestBegin pipeline
I decided to try adding some debugging to a clean installation of Sitecore 7.2.
I created the following simple class:
using Sitecore.Diagnostics;
using Sitecore.Pipelines;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;
namespace SCMVC72.Pipelines
{
public class DebugStackTrace
{
public void Process(PipelineArgs args)
{
StackTrace st = new StackTrace();
Log.Info(string.Empty, (object)this);
Log.Info("*********************************************************************", (object)this);
Log.Info("Debug StackTrace", (object)this);
Log.Info(st.ToString(), (object)this);
Log.Info("*********************************************************************", (object)this);
}
}
}
And the I added the following config file in the App_Config\Include folder:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<initialize>
<processor type="SCMVC72.Pipelines.DebugStackTrace, SCMVC72"
patch:before="processor[#type='Sitecore.Pipelines.Loader.ShowVersion, Sitecore.Kernel']" />
</initialize>
</pipelines>
</sitecore>
</configuration>
On application restart, This is the output I got in the logs:
5764 14:38:08 INFO HttpModule is being initialized
5764 14:38:08 INFO
5764 14:38:08 INFO *********************************************************************
5764 14:38:08 INFO Debug StackTrace
5764 14:38:08 INFO at SCMVC72.Pipelines.DebugStackTrace.Process(PipelineArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Nexus.Web.HttpModule.Application_Start()
at Sitecore.Nexus.Web.HttpModule.Init(HttpApplication app)
at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)
at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)
5764 14:38:08 INFO *********************************************************************
Which was output right befor the famous:
5764 14:38:08 INFO
5764 14:38:08 INFO **********************************************************************
5764 14:38:08 INFO **********************************************************************
5764 14:38:08 INFO Sitecore started
5764 14:38:08 INFO Sitecore.NET 7.2 (rev. 140228)
This confirms what HRH John West said when he wrote that "this happens in one of the obfuscated assemblies" - Sitecore.Nexus, to be more precise.
There is a SetActiveSite method in the Sitecore.Context class. This runs the Intialize pipeline, and there are a few places from which the method is called.
JobRunner.InitalizeContext
MediaCreator.SetContext
MediaRequestHandler.RedirectIfUserShouldBeLoggedIn
WebDavMediaRequestHandler.ProcessRequest
So it appears to be linked with initialization of a context, and therefore not just at the beginning of the application.
For information, I found this by searching for "Initalize" (with the quotes included), which found this:
CorePipeline.Run("initialize", new PipelineArgs());