2

In the Sitecore® Experience Solution Developer Course you learn to set up a Visual Studio solution for Sitecore 8 by doing the following steps:

  1. Create a new ASP.NET Web Application using the Empty ASP.NET 4.5.2 Template.
  2. Copy the Global.asax, Web.config, Views\Web.config files from the Sitecore Website folder into your Visual Studio project folder.
  3. Add the assemblies Sitecore.Kernel.dll, Sitecore.MVC.Analytics.dll, and Sitecore.MVC.dll to your Visual Studio project.
  4. Create a folder named App_Config in your Visual Studio project.

Optionally, you navigate to the Global.asax file and investigate the error list. If you notice that there are warnings, you can install the following NuGet packages with their depending packages.

  • Microsoft.ASPNET.WebApi
  • Microsoft.ASPNET.WebApi.Cors

These steps were not enough to fix the warnings in the Global.asax file. I had to install the following NuGet packages

  • Microsoft.AspNet.Mvc
  • Microsoft.AspNet.WebPages

Recently, I followed these steps when setting up a Visual Studio solution for Sitecore 9.0 (Initial Release) and it worked fine.

Now, I am trying to do the same with Sitecore 9.0 Update-1, but I still get warnings from the Global.asax.

The first warning was:

ASP.NET runtime error: The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Unable to open configSource file 'App_Config\Sitecore.config'

After adding the App_Config\Sitecore.config file to the Visual Studio project, it complained about more missing config files. After adding them, it started showing the following warning:

ASP.NET runtime error: The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.

I installed the Microsoft.Extensions.DependencyInjection NuGet package. After that, it started giving me the following warning.

ASP.NET runtime error: The pre-application start initialization method Start on type WebMatrix.WebData.PreApplicationStartCode threw an exception with the following error message: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

I tried to fix it by installing the NETStandard.Library NuGet package, but it didn't fix it. I ended up with a Visual Studio solution like that.

How my Visual Studio solution looked like afterwards

Have you guys managed to fix these warnings or do you advise me simply ignoring them?

Update: I am setting up a Visual Studio solution using .NET Framework 4.7 and an Empty ASP.NET Web Application (.NET Framework) template. I am using Visual Studio 2017.

2
  • 2
    It is generally recommended not to mess with or edit the Global.asax file in Sitecore solutions (and instead use Initialize pipeline for anything you would normally do there). Do you get all the errors if you remove this file?
    – jammykam
    Commented Jan 11, 2018 at 17:37
  • By removing Global.asax I don't get warnings anymore. I wonder why Sitecore would teach you to add this file in the first place. It is in the Sitecore® Experience Solution Developer Course I did 6 months ago.
    – João Neto
    Commented Jan 12, 2018 at 10:50

1 Answer 1

2

As suggested by @jammykam, I removed the Global.asax. It stopped the warnings being popped up in my Visual Studio. I don't know why the Sitecore online training teaches you to add this file to the Visual Studio project, but you shouldn't do it as it is NOT recommended adding custom code to Global.asax. If you need anything that you think should go no Global.asax, please use the Initialize pipeline or create a custom Http Module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.