Welcome to the navigation

Sed officia sint voluptate magna sunt consectetur irure aliqua, cupidatat in esse nulla commodo deserunt laboris proident, id elit, ut duis adipisicing ipsum dolor do. Ad ut ea aliqua, irure cupidatat est ex nulla cillum lorem incididunt dolore elit, voluptate commodo consectetur magna laboris nisi deserunt dolore sint in exercitation

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!