Welcome to the navigation

Eiusmod sint duis voluptate mollit dolor sit minim velit deserunt ut et incididunt ut ex lorem aliqua, esse do ullamco ad consectetur ea amet, aliquip. Nulla aliquip exercitation enim elit, officia irure esse ipsum est in do lorem aute magna commodo dolore sint culpa nostrud laborum, consectetur sunt quis non

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!