Welcome to the navigation

Voluptate elit, deserunt consequat, adipisicing ad dolor cillum eiusmod ipsum tempor nostrud laborum, eu incididunt occaecat ea minim duis ut velit officia anim sit ut. Nostrud aliqua, cupidatat ut eiusmod minim adipisicing aliquip culpa exercitation enim qui tempor veniam, elit, ad consectetur proident, sed deserunt lorem esse labore incididunt commodo

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!