Unable to load DLL 'SqlServerSpatial140.dll': The specified module could not be found

Copy the dll from C:\Users\<User>\.nuget\packages\Microsoft.SqlServer.Types\14.0.314.76\nativeBinaries\x86 to your project. Right-click the file and click Properties. Set "Copy To Output Directory" to "Copy Always".


When you install the Microsoft.SqlServer.Types nuget package, this should create a new folder in root:

\SqlServerTypes
   |_x64
   |_x86

which should contain the appropriate dll's. It's also auto setup to copy if newer.

Then, make sure your app loads the appropriate assembly:

  • For ASP.NET Web Applications: SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
  • For desktop applications / others: SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);

Not sure if this works with .NET Core though.


For those who are seeing a very similar set of errors, something like:

Could not copy the file "…\SqlServerTypes\x64\SqlServerSpatial140.dll" because it was not found

If you installed Microsoft.SqlServer.Types via NuGet and your application works locally but you get errors when building via Azure DevOps then you simply need to add the dlls to source control. As @Pure.Krome noted, these dlls exist locally at:

enter image description here

However, notice that by default these dlls are ignored (red icon at left). Right-click the ignored dlls and select Add Ignored File to Source Control… then commit and push your changes, then queue a new build! Note: Your solution may contain several projects, and each may have their own SqlServerTypes folder.