11
votes

I'm trying to get the nuget package Microsoft.SqlServer.Types to work in ASP Core targeting full framework 461. I need to use the types SqlGeography and SqlHierarchyId. But when I run my test I get following error 'Unable to load DLL SqlServerSpatial140.dll'. I know when the package is installed the dlls file can be found in the .nuget\packages\microsoft.sqlserver.types\14.0.314.76\nativeBinaries\ folder.

But how do I include the dlls in my solution the best way?

I would like the dlls to be updated when the package is updated. The path can not be hardcode to a specific user path, it has to work on every pc setup.

1

1 Answers

1
votes

There is a readme.htm file included with the Microsoft.SqlServer.Types Nuget package. It will explain how to load the needed native dll files. Basically you need to call this line in your code:

SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);