0
votes

I had write an api in WebApi, that was working in local fine, but when i moved it to server then it is showing the following error,

{"Message":"An error has occurred.","ExceptionMessage":"Spatial types and functions are not available for this provider because the assembly 'Microsoft.SqlServer.Types' version 10 or higher could not be found. ","ExceptionType":"System.InvalidOperationException","StackTrace":" at System.Data.Entity.SqlServer.SqlTypesAssemblyLoader.GetSqlTypesAssembly()\r\n at System.Data.Entity.SqlServer.SqlSpatialDataReader.<.cctor>b__0()\r\n at System.Lazy1.CreateValue()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Lazy1.get_Value()\r\n at System.Data.Entity.SqlServer.SqlSpatialDataReader.GetGeography(Int32 ordinal)\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader1.GetValue(DbDataReader reader, Int32 ordinal)\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Shaper.GetSpatialColumnValueWithErrorHandling[TColumn](Int32 ordinal, PrimitiveTypeKind spatialTypeKind)\r\n at lambda_method(Closure , Shaper )\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Coordinator1.ReadNextElement(Shaper shaper)\r\n at System.Data.Entity.Core.Common.Internal.Materialization.Shaper1.SimpleEnumerator.MoveNext()\r\n at System.Collections.Generic.List1..ctor(IEnumerable1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)\r\n at Portal.Repository.ApplicationRepository.d__0.MoveNext() in C:\agent\_work\31\s\Portal\Repository\ApplicationRepository.cs:line 17\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at Portal.Controllers.AppController.d__0.MoveNext() in C:\\agent\\_work\\31\\s\\Portal\\Controllers\\AppController.cs:line 21\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.d__31.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.AuthenticationFilterResult.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"}

How can i rectify this ? please help me..

1
By adding some SQL Server Related dll's it works fine in server. refer this link blogs.msdn.microsoft.com/adonet/2013/12/09/…chaitanya k

1 Answers

2
votes

Take a look at https://www.nuget.org/packages/Microsoft.SqlServer.Types/ if the assembly isn't on the server you will have to make it available yourself.