SqlServer Spatial DataReader.GetFieldType returned null

I have a .net4.5 web application project that uses the SQL server spatial data type.

It works fine locally on the development machine, but when deployed to the application server, I get the following error when trying to run queries in a table with spatial data:

System.InvalidOperationException: DataReader.GetFieldType(5) returned null.

I found that if SQLServer is not installed on the server, support for spatial data types is not supported.

So I installed the nuget package in my project:

Install-Package Microsoft.SqlServer.Types

This added links to Microsoft.SqlServer.Types files and created the SqlServerTypes folder containing some DLLs.

After redeploying the project to the server, it still does not work (same error).

The instructions from the nuget package say that I should add the following line to the applciaion_start event:

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

, squiggly SqlServerTypes "SqlServerTypes " Visual Studio.

Imports Microsoft.SqlServer.Types

SqlServerTypes .

+4
1

nuget Microsoft.SqlServer.Types #.

, vb.net.

, :

Install-Package Microsoft.SqlServer.Types

:

/SqlServerTypes/Loader.cs

Loader.cs vb ( -) : Loader.vb

SqlServerTypes .

+3

Source: https://habr.com/ru/post/1539917/


All Articles