0

My WebRole won't start but keeps restarting and throws this exception:

Application: WaIISHost.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: 
 System.IO.FileLoadException: Could not load file or assembly 'Autofac, Version=3.4.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'Autofac, Version=3.4.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da'
   at MyDomain.Web.AutofacWebModule.Load(ContainerBuilder builder)
   at Autofac.Module.Configure(IComponentRegistry componentRegistry)
   at Autofac.ContainerBuilder.Build(IComponentRegistry componentRegistry, Boolean excludeDefaultModules)
   at Autofac.ContainerBuilder.Build(ContainerBuildOptions options)
   at MyDomain.Web.Startup.BuildAutofacContainer() in MyDomain.Web\Startup.cs:line 82
   at MyDomain.Web.WebRole.Run() in MyDomain.Web\WebRole.cs:line 25
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StartRoleInternal()
   at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<StartRole>b__2()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

UPDATE. Added a full error description with the help of this article: Troubleshooting Scenario 7 – Role Recycling

UPDATE 2. Found a good article about the exception. Cloud Services roles recycling with the error “System.IO.FileLoadException: Could not load file or assembly”. It seems to be enough to fix the problem.

The reason it breaks is on my Azure instance, in E:\approot\bin\ there is no MyDomain.Web.config files with the redirections required by Autofac. And the web.config in E:\approot\ is not read by the WaIISHost.exe. And so it breaks.

Artyom
  • 3,507
  • 2
  • 34
  • 67

1 Answers1

0

It needed the <role name>.dll.config file added to solution (same level as the web.config or app.config) (the Copy to Output Directory property to “Copy Always”). Then redeploying to Azure. This file should contain the bindingRedirect settings.

Artyom
  • 3,507
  • 2
  • 34
  • 67