"空间类型和功能不适用于此提供商"应用程序移动到服务器

时间:2018-01-13 07:05:50

标签: c# sql-server linq asp.net-web-api linq-to-sql

我在WebApi中编写了一个API,它在本地工作正常,但当我将它移动到服务器时,它显示以下错误,

  

{"消息":"发生错误。"," ExceptionMessage":"空间类型   并且函数不适用于此提供程序,因为程序集   ' Microsoft.SqlServer.Types'找不到版本10或更高版本。   "" ExceptionType":" System.InvalidOperationException""堆栈跟踪":"在   System.Data.Entity.SqlServer.SqlTypesAssemblyLoader.GetSqlTypesAssembly(个)\ r \ n   在   System.Data.Entity.SqlServer.SqlSpatialDataReader< .cctor> b__0(个)\ r \ n   在System.Lazy 1.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.Lazy 1.get_Value()\ r \ n at   System.Data.Entity.SqlServer.SqlSpatialDataReader.GetGeography(的Int32   序数)\ r \ n at   System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader 1.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.Coordinator 1.ReadNextElement(整形器   塑造者)\ r \ n at   System.Data.Entity.Core.Common.Internal.Materialization.Shaper 1.SimpleEnumerator.MoveNext()\r\n at System.Collections.Generic.List 1..ctor(IEnumerable 1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable 1 source)\ r \ n at   Portal.Repository.ApplicationRepository.d__0.MoveNext()in   C:\剂\ _work \ 31个\ S \门户\库\ ApplicationRepository.cs:线   17 \ r \ n ---来自先前位置的堆栈跟踪结束异常   被扔了--- \ r \ n at   System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\ r \ n at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)\ r \ n at   System.Runtime.CompilerServices.TaskAwaiter 1.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__3 1.MoveNext(个)\ r \ n ---   从抛出异常的先前位置开始的堆栈跟踪结束   --- \ r \ n在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\ r \ n at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)\ r \ n at   System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext(个)\ r \ n ---   从抛出异常的先前位置开始的堆栈跟踪结束   --- \ r \ n在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\ r \ n at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)\ r \ n at   System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext(个)\ r \ n ---   从抛出异常的先前位置开始的堆栈跟踪结束   --- \ r \ n在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\ r \ n at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)\ r \ n at   System.Web.Http.Controllers.AuthenticationFilterResult.d__0.MoveNext(个)\ r \ n ---   从抛出异常的先前位置开始的堆栈跟踪结束   --- \ r \ n在System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\ r \ n at   System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务   任务)\ r \ n at   System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"}

我怎样才能纠正这个?请帮帮我..

1 个答案:

答案 0 :(得分:2)

如果程序集不在服务器上,请查看https://www.nuget.org/packages/Microsoft.SqlServer.Types/,您必须自己使用它。