问题
I'm getting the error:
Spatial types and functions are not available for this provider, because the assembly "Microsoft.SqlServer.Types" version 10 or higher could not be found.
I'm only getting this error on one of my dev machines - on the other, it works correctly. Both machines have SQL Server 2014 installed on them, which ought to be enough, but apparently it's not. Beyond that, I've installed the nuget package "Microsoft.SqlServer.Types" in the solution (I've tried it in several of the subordinate projects as well), and have added the appropriate lines to load the DLLs in question:
Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);
Debugging shows that the line in question executes, and stepping into it, it appears that the DLLs in question load successfully.
The same machine used to run the project (a unit test assembly) without errors. The error started showing up about the same time that I switched the test project over to xUnit from MSTest, so it may very well be related to that.
Any suggestions for troubleshooting this?
回答1:
FWIW, I eventually managed to get this working by including the Microsoft.SqlServer.Types in every top-level project, including unit tests, and loading the DLLs via the LoadNativeAssemblies
method separately in each top-level project. The documentation made no note of this, but it was the only thing I could come up with that worked.
回答2:
Downgrading to Microsoft.SqlServer.Types Version 11.0.2 worked for me.
来源:https://stackoverflow.com/questions/34561891/error-spatial-types-and-functions-are-not-available-for-this-provider