Could not load file or assembly 'DocumentDB.Spatial.Sql' or one of its dependencies

3

I updated all my nuget packages to the latest versions. Everything works great locally whether in debug or release, but as soon as i published to azure, i get this on the website main page:

[FileLoadException: Could not load file or assembly 'DocumentDB.Spatial.Sql' or one of its dependencies. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)]
   System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
   System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +457
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +110
   System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +22
   System.Reflection.Assembly.Load(String assemblyString) +34
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +48

[ConfigurationErrorsException: Could not load file or assembly 'DocumentDB.Spatial.Sql' or one of its dependencies. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +729
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +247
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +157
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +226
   System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +73
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +321
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +170
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +878

[HttpException (0x80004005): Could not load file or assembly 'DocumentDB.Spatial.Sql' or one of its dependencies. Could not find or load a specific file. (Exception from HRESULT: 0x80131621)]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +124
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +700

These are the Nuget packages installed:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="jQuery" version="3.2.1" targetFramework="net452" />
  <package id="Microsoft.AspNet.SignalR" version="2.2.2" targetFramework="net452" />
  <package id="Microsoft.AspNet.SignalR.Core" version="2.2.2" targetFramework="net452" />
  <package id="Microsoft.AspNet.SignalR.JS" version="2.2.2" targetFramework="net452" />
  <package id="Microsoft.AspNet.SignalR.SystemWeb" version="2.2.2" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net452" />
  <package id="Microsoft.Azure.DocumentDB" version="1.18.0" targetFramework="net452" />
  <package id="Microsoft.Azure.DocumentDB.ChangeFeedProcessor" version="1.2.0" targetFramework="net452" />
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.8" targetFramework="net452" />
  <package id="Microsoft.Net.Compilers" version="2.4.0" targetFramework="net452" developmentDependency="true" />
  <package id="Microsoft.Owin" version="4.0.0-alpha1" targetFramework="net452" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="4.0.0-alpha1" targetFramework="net452" />
  <package id="Microsoft.Owin.Security" version="4.0.0-alpha1" targetFramework="net452" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
  <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net452" />
  <package id="Owin" version="1.0" targetFramework="net452" />
</packages>

Publish build log:

1>------ Publish started: Project: redacted, Configuration: Release Any CPU ------
1>Transformed Web.config using C:\Projects\redacted\redacted\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.
1>Auto ConnectionString Transformed obj\Release\TransformWebConfig\transformed\Web.config into obj\Release\CSAutoParameterize\transformed\Web.config.
1>Copying all files to temporary location below for package/publish:
1>obj\Release\Package\PackageTmp.
1>Start Web Deploy Publish the Application/package to https://redacted.scm.azurewebsites.net/msdeploy.axd?site=redacted ...
1>Adding ACLs for path (redacted)
1>Adding ACLs for path (redacted)
1>Updating file (redacted\bin\DocumentDB.Spatial.Sql.dll).
1>Updating file (redacted\bin\redacted.dll).
1>Updating file (redacted\bin\Microsoft.Azure.Documents.Client.dll).
1>Updating file (redacted\bin\Microsoft.Azure.Documents.ServiceInterop.dll).
1>Updating file (redacted\packages.config).
1>Updating file (redacted\Web.config).
1>Adding ACLs for path (redacted)
1>Adding ACLs for path (redacted)
1>Publish Succeeded.
1>Web App was published successfully http://redacted.azurewebsites.net/
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========

You can see the target DLL getting added to the package in the build process.

I can't get it out of this state -- it's on a dev server and now my frontend devs are getting anxious.

I have tried rolling back DocumentDB, that didn't help. This happened after i reluctantly decided to update the nuget packages.

It looks like the DocumentDB.Spatial.Sql.dll file isn't even a .net assembly. Why is it trying to load it as such? It's just a native 64bit DLL.

This is an image of my deployed project on my azure site: enter image description here

c#
.net
azure
azure-web-app-service
asked on Stack Overflow Nov 5, 2017 by Andy • edited Nov 5, 2017 by Andy

1 Answer

3

So if anyone else has this issue or similar, it is a bug with the publish tool. What I did to resolve it was:

  1. Update all your Nuget packages
  2. Shut down Visual Studio
  3. Delete your local project\bin and project\obj directories
  4. Open Visual Studio and rebuild the RELEASE package
  5. Go to Azure web app and STOP the app
  6. Open FTP client, connect to your website
  7. Delete all the files in the /site/wwwroot/bin directory
  8. Manually upload all the files in the project\bin directory to /site/wwwroot/bin directory
  9. Start your Azure web app

That got everything working again for me.

What I am thinking is there was some left over stuff from the older Nuget packages that was causing conflicts. This just makes sure that after you update your Nuget packages that your live website is starting with a clean slate.

answered on Stack Overflow Nov 5, 2017 by Andy • edited Nov 5, 2017 by Andy

User contributions licensed under CC BY-SA 3.0