“Spatial types and functions are not available” error when converting a string to DbGeometry in ASP.NET

前端 未结 1 948
故里飘歌
故里飘歌 2021-01-24 06:07

When trying to convert a string as below

52.0986413 5.2171528

to a variable of type DbGeometry like this

Geometry          


        
相关标签:
1条回答
  • 2021-01-24 07:02

    I found the answer when I reinstalled Microsoft.SqlServer.Types.

    For ASP.NET applications, add the following line of code to the Application_Start method in Global.asax.cs:

    SqlServerTypes.Utilities.LoadNativeAssemblies(Server.MapPath("~/bin"));
    

    For desktop applications, add the following line of code to run before any spatial operations are performed:

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

    This fixed it for me

    0 讨论(0)
提交回复
热议问题