Web Service fails to start: Could not load file or assembly
<p>I have a problem with a web service that will not run anymore. It previously had the 64-bit version installed, but now the 32-bit is installed. However, it seems that it is looking for a 64-bit version of the ChilkatDotNet2.dll, which is strange. The version that was installed by the MSI-package is X86.</p>

<blockquote>
  <p>C:\Program Files (x86)\Sipp\Market Server\bin>asminfo.exe
  ChilkatDotNet2.dll ChilkatDotNet2, Version=9.3.0.0, Culture=neutral,
  PublicKeyToken=eb5fc1fc52ef09b d | X86</p>
</blockquote>

<p>I enabled FusionLog and it gave the following output:</p>

<blockquote>
  <p>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. </p>
  
  <p>Exception Details: System.BadImageFormatException: Could not load file
  or assembly 'ChilkatDotNet2' or one of its dependencies. An attempt
  was made to load a program with an incorrect format.</p>
  
  <p>Source Error: </p>
  
  <p>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.</p>
  
  <p>Assembly Load Trace: The following information can be helpful to
  determine why the assembly 'ChilkatDotNet2' could not be loaded.</p>
  
  <p>=== Pre-bind state information === LOG: User = SF\sonsupport LOG: DisplayName = ChilkatDotNet2  (Partial) LOG: Appbase =
  file:///C:/Program Files (x86)/Sipp/Market Server/ LOG: Initial
  PrivatePath = C:\Program Files (x86)\Sipp\Market Server\bin Calling
  assembly : (Unknown).
  === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Program Files (x86)\Sipp\Market
  Server\web.config LOG: Using host configuration file:
  C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Aspnet.config LOG:
  Using machine configuration file from
  C:\Windows\Microsoft.NET\Framework64\v2.0.50727\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/v2.0.50727/Temporary
  ASP.NET Files/server/b8e4736f/d41d574d/ChilkatDotNet2.DLL. LOG:
  Attempting download of new URL
  file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary
  ASP.NET
  Files/server/b8e4736f/d41d574d/ChilkatDotNet2/ChilkatDotNet2.DLL. LOG:
  Attempting download of new URL file:///C:/Program Files
  (x86)/Sipp/Market Server/bin/ChilkatDotNet2.DLL. ERR: Failed to
  complete setup of assembly (hr = 0x8007000b). Probing terminated.</p>
  
  <p>Stack Trace: </p>
  
  <p>[BadImageFormatException: Could not load file or assembly
  'ChilkatDotNet2' or one of its dependencies. An attempt was made to
  load a program with an incorrect format.]<br>
  System.Reflection.Assembly._nLoad(AssemblyName fileName, String
  codeBase, Evidence assemblySecurity, Assembly locationHint,
  StackCrawlMark&amp; stackMark, Boolean throwOnFileNotFound, Boolean
  forIntrospection) +0<br>
  System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef,
  Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean
  forIntrospection) +416<br>
  System.Reflection.Assembly.InternalLoad(String assemblyString,
  Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean
  forIntrospection) +166    System.Reflection.Assembly.Load(String
  assemblyString) +35<br>
  System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String
  assemblyName, Boolean starDirective) +190</p>
  
  <p>[ConfigurationErrorsException: Could not load file or assembly
  'ChilkatDotNet2' or one of its dependencies. An attempt was made to
  load a program with an incorrect format.]<br>
  System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String
  assemblyName, Boolean starDirective) +11241896<br>
  System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
  +388    System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo
  ai) +232<br>
  System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +48<br>
  System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection
  compConfig) +210<br>
  System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory
  vdir) +191<br>
  System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory
  vdir, Boolean ignoreErrors) +54<br>
  System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath
  virtualPath) +295<br>
  System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath
  virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean
  allowBuildInPrecompile) +476<br>
  System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext
  context, VirtualPath virtualPath, Boolean noBuild, Boolean
  allowCrossApp, Boolean allowBuildInPrecompile) +116<br>
  System.Web.Compilation.BuildManager.GetCompiledCustomString(String
  virtualPath) +39<br>
  System.ServiceModel.HostingManager.GetCompiledCustomString(String
  normalizedVirtualPath) +202<br>
  System.ServiceModel.HostingManager.CreateService(String
  normalizedVirtualPath) +33<br>
  System.ServiceModel.HostingManager.ActivateService(String
  normalizedVirtualPath) +46<br>
  System.ServiceModel.HostingManager.EnsureServiceAvailable(String
  normalizedVirtualPath) +654</p>
  
  <p>[ServiceActivationException: The service '/server/service.svc' cannot
  be activated due to an exception during compilation.  The exception
  message is: Could not load file or assembly 'ChilkatDotNet2' or one of
  its dependencies. An attempt was made to load a program with an
  incorrect format..]<br>
  System.ServiceModel.AsyncResult.End(IAsyncResult result) +15778592<br>
  System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult
  result) +15698937<br>
  System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication
  context, Boolean flowContext) +265<br>
  System.ServiceModel.Activation.HttpModule.ProcessRequest(Object
  sender, EventArgs e) +227<br>
  System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
  +80    System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +171</p>
</blockquote>
