title: What would cause a 'could not load file or assembly' error concerning 'Microsoft.WindowsAzure.Configuration'?
body: <p>I have a multi-tier Azure application I've been working on. It uses web and worker roles behind an MVC front end, as well as Azure SQL and Table storage. It has been working well for a while, both in the emulator and the cloud. </p>
  
  <p>I've just started adding some Service Bus functionality to it, adding the Service Bus package from NuGet, and now I find that although everything still compiles, I am getting the following runtime error:</p>
  
  <pre><code>Server Error in '/' Application.
  Could not load file or assembly 'Microsoft.WindowsAzure.Configuration' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
  
  Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Configuration' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)
  
  Source Error:
  
  An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
  
  Assembly Load Trace: The following information can be helpful to determine why the assembly 'Microsoft.WindowsAzure.Configuration' could not be loaded.
  
  
  === Pre-bind state information ===
  LOG: User = JCFXLAPTOP\User
  LOG: DisplayName = Microsoft.WindowsAzure.Configuration
   (Partial)
  WRN: Partial binding information was supplied for an assembly:
  WRN: Assembly Name: Microsoft.WindowsAzure.Configuration | Domain ID: 2
  WRN: A partial bind occurs when only part of the assembly display name is provided.
  WRN: This might result in the binder loading an incorrect assembly.
  WRN: It is recommended to provide a fully specified textual identity for the assembly,
  WRN: that consists of the simple name, version, culture, and public key token.
  WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
  LOG: Appbase = file:///D:/Work/CLIENTS/PageEngine/Solutions/PageEngine/Web.PageEngine/
  LOG: Initial PrivatePath = D:\Work\CLIENTS\PageEngine\Solutions\PageEngine\Web.PageEngine\bin
  Calling assembly : (Unknown).
  ===
  LOG: This bind starts in default load context.
  LOG: Using application configuration file: D:\Work\CLIENTS\PageEngine\Solutions\PageEngine\Web.PageEngine\web.config
  LOG: Using host configuration file: C:\Program Files\IIS Express\config\templates\PersonalWebServer\aspnet.config
  LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
  LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
  LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/4904ccbc/14659c77/Microsoft.WindowsAzure.Configuration.DLL.
  LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/4904ccbc/14659c77/Microsoft.WindowsAzure.Configuration/Microsoft.WindowsAzure.Configuration.DLL.
  LOG: Attempting download of new URL file:///D:/Work/CLIENTS/PageEngine/Solutions/PageEngine/Web.PageEngine/bin/Microsoft.WindowsAzure.Configuration.DLL.
  LOG: Using application configuration file: D:\Work\CLIENTS\PageEngine\Solutions\PageEngine\Web.PageEngine\web.config
  LOG: Using host configuration file: C:\Program Files\IIS Express\config\templates\PersonalWebServer\aspnet.config
  LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
  LOG: Post-policy reference: Microsoft.WindowsAzure.Configuration, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  ERR: Failed to complete setup of assembly (hr = 0x80131045). Probing terminated.
  
  
  Stack Trace:
  
  
  [FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Configuration' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)]
  
  [FileLoadException: Could not load file or assembly 'Microsoft.WindowsAzure.Configuration, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)]
     System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
     System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
     System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
     System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean forIntrospection) +17
     System.Reflection.Assembly.Load(String assemblyString) +35
     System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122
  
  [ConfigurationErrorsException: Could not load file or assembly 'Microsoft.WindowsAzure.Configuration, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)]
     System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12731430
     System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +503
     System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142
     System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
     System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +203
     System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
     System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151
  
  [HttpException (0x80004005): Could not load file or assembly 'Microsoft.WindowsAzure.Configuration, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Strong name signature could not be verified.  The assembly may have been tampered with, or it was delay signed but not fully signed with the correct private key. (Exception from HRESULT: 0x80131045)]
     System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12847312
     System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
     System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12675965
  </code></pre>
  
  <p>I noticed that the ServiceBus NuGet package references a newer version of the Microsoft.WindowsAzure.Configuration dll (1.7.0.2), and wondered if that might be the cause. I've tried overriding this and changing all references to either 1.7.0.0 or 1.7.0.2 - neither change helped. I've also tried removing all Azure references from the solution and re-adding references by installing NuGet packages and referencing the latest SDK. This hasn't helped either.</p>
  
  <p>I should add that at all times the Microsoft.WindowsAzure.Configuration dll has been in the bin folder of the MVC application, and that it has always had CopyLocal set to true.</p>
  
  <p>I note that the Azure Configuration NuGet package was updated very recently (Friday 27th July), and I wonder if that might have something to do with it.</p>
  
  <p>Does anybody know what the issue could be?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Just to confirm that removing the service bus nuget package fixes the problem. Reinstating it causes the problem to recur. I don't know if this matters but the Microsoft.WindowsAzure.Configuration dll added as part of the NuGet package seems to have an inconsistent version number. While the path suggests the version should be 1.7.0.2:</p>
  
  <p>D:\Work\CLIENTS\PageEngine\Solutions\PageEngine\packages\Microsoft.WindowsAzure.ConfigurationManager.<strong>1.7.0.2</strong>\lib\net35-full\Microsoft.WindowsAzure.Configuration.dll</p>
  
  <p>... the version number in the properties inspector is still 1.7.0.0</p>