Welcome to the navigation

In in anim nostrud velit voluptate amet, sed nulla ex adipisicing ut et esse elit, proident, aliqua, magna dolore nisi id laboris qui non mollit. Proident, irure nisi quis occaecat pariatur, incididunt non labore ullamco reprehenderit sint laborum, dolor enim sunt elit, eiusmod magna dolore duis sit ut anim cillum

Yeah, this will be replaced... But please enjoy the search!

Episerver: Could not load file or assembly StructureMap.Web

Upgraded some Episerver packages and ended up with bad assembly references. 

The error

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

Stack Trace

[FileLoadException: Could not load file or assembly 'StructureMap.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
   EPiServer.ServiceLocation.Internal.StructureMapLifecycleTransformer.GetLifeCycle(ServiceInstanceScope scope) +0
   EPiServer.ServiceLocation.Internal.StructureMapConfiguredType`1.LifecycleIs(ServiceInstanceScope lifecycle) +27
...

Solution

So somehow the upgrade linked the wrong nuget package

This can be confirmed by checking the csproj-file

<Reference Include="StructureMap.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223, processorArchitecture=MSIL">
  <HintPath>..\packages\structuremap.web-signed.3.1.6.191\lib\net40\StructureMap.Web.dll</HintPath>
</Reference>

 Solution

Check your packages folder, I'd bet there is another version of StructureMap available, in my case 

<Reference Include="StructureMap.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e60ad81abae3c223, processorArchitecture=MSIL">
  <HintPath>..\packages\structuremap.web.4.0.0.315\lib\net40\StructureMap.Web.dll</HintPath>
</Reference>

Replacing the structuremap.web-signed.3.1.6.191 with the correct version structuremap.web.4.0.0.315.

You may also need to reinstall the package using the nuget console

Update-Package StructureMap.Web -Reinstall

Clean and rebuild!