I am getting an error as:

Could not load file or assembly 'Microsoft.Extensions.DependencyInjection, Version=, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.

While accessing Sitecore FakeDB in my MSTEST unit testing project.

  • Sitecore Version : 8.2 update 2
  • Sitecore FakeDB: 1.7.4
  • .Net Framework: 4.5.2

What can be the issue here?

  • can you check the version of Microsoft.Extensions.DependencyInjection dll in your website? Commented Mar 31, 2021 at 12:43
  • In my Sitecore application it is Commented Mar 31, 2021 at 12:49
  • Not sure how you are referencing the dll (nuget package or dll reference) in your Test project, but you can take a look at what version it is set in the Project/References. Commented Mar 31, 2021 at 12:50
  • I have DLL reference of Sitecore.Kernel.dll v8.2 update 2 same dll i have referred in Unit testing project whereas I have referred nuget package of Sitecore Fake DB v 1.7.4. With higher version of fakedb dll is not getting resolved as i have dot net framework 4.5.2 Commented Mar 31, 2021 at 12:54
  • Can you try to add a reference in your Test project to the Microsoft.Extensions.DependencyInjection dll or use the nuget package? Commented Mar 31, 2021 at 13:15

3 Answers 3


I remember having some issues with error messages not corresponding to the actual issue. If you can make sure of all of these (assuming you are following Helix principles here):

Declare databases configuration on each projects (ex : Feature/YourFeautre/App_Config/Include/Feature/Sitecore.license.config)

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <database id="core">
        <patch:attribute name="type">Sitecore.Data.DefaultDatabase, Sitecore.Kernel</patch:attribute>
      <database id="master">
        <patch:attribute name="type">Sitecore.Data.DefaultDatabase, Sitecore.Kernel</patch:attribute>
      <database id="web">
        <patch:attribute name="type">Sitecore.Data.DefaultDatabase, Sitecore.Kernel</patch:attribute>
    <!-- EVENTING -->
    <eventing defaultProvider="sitecore">
        <clear />
        <add name="sitecore" type="Sitecore.Eventing.EventProvider, Sitecore.Kernel" systemDatabaseName="core" />

Declare the license configuration on each projects.(ex : Feature/YourFeautre/App_Config/Include/Feature/Sitecore.license.config)

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <setting name="LicenseFile" value="C:\inetpub\wwwroot\yourInstance\App_Data\license.xml" />

Then in your tests, you should be using these :

using Sitecore.Data;
using Sitecore.FakeDb;
using Sitecore.Mvc.Presentation;
using Xunit;

In your projects references, you should have those : enter image description here

Official doc said you need those :


But I make it work without Sitecore.Analytics.dll and Sitecore.Logging.dll

After it is all said and done, make sure you are using compatible versions within your projects. I think your Microsoft.Extensions.DependencyInjection is good, would also make sure to have Microsoft.Extensions.DependencyInjection.Abstractions in your references. So within your packages.config it should look like this :

<?xml version="1.0" encoding="utf-8"?>
  <!-- [...your other packages...] -->
  <package id="Microsoft.Extensions.DependencyInjection" version="1.0.0" targetFramework="net452" />
  <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="1.0.0" targetFramework="net452" />

I would also recommend to take a look at this answer : https://stackoverflow.com/questions/39802162/what-is-the-minimum-nugets-footprint-for-sitecore-fakedb-tests/39802163 because it feels like, in your similar case, you would end up using this fakedb version :

 <package id="Sitecore.FakeDb" version="1.2.2" targetFramework="net452" />

and also include sitecore.logging

<package id="Sitecore.Logging.NoReferences" version="8.2.160729" targetFramework="net452" developmentDependency="true" />

You should make sure that your Test project has at least the following references:

  <package id="Lucene.Net" version="3.0.3" targetFramework="net452" />
  <package id="Microsoft.Extensions.DependencyInjection" version="1.0.0" targetFramework="net452" />
  <package id="Sitecore.FakeDb" version="1.7.4" targetFramework="net452" />
  <package id="Sitecore.Kernel.NoReferences" version="8.2.161221" targetFramework="net452" developmentDependency="true" />
  <package id="Sitecore.Logging.NoReferences" version="8.2.161221" targetFramework="net452" developmentDependency="true" />
  <package id="Sitecore.Nexus.NoReferences" version="8.2.161221" targetFramework="net452" developmentDependency="true" />

You only need to add two nuget packages in your solution with the dependencies: Sitecore.Nexus and Microsoft.Extensions.DependencyInjection.


Thanks for the Response.

I have reinstalled Sitecore using nuget package. I have verified steps provided Jean-Nicolas G. response.

It did worked.

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.