Azure Geomentry 类型引发异常无法加载文件或程序集 microsoft.sqlserver.types,版本=11.0.0.0

标签 azure filenotfoundexception sqlexception

我在 Azure 上托管 Restful 服务。效果很好。但今天我发现使用 Geometry 类型的方法会抛出异常。有趣的是我没有更新任何东西。

我使用 NuGet Package 并引用 microsoft.sqlserver.types,Version=10.0.0.0,效果很好。

异常(exception):

System.Data.Entity.Infrastructure.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> 
System.Data.UpdateException: An error occurred while updating the entries. See the inner exception for details. ---> 
System.Data.SqlClient.SqlException: An error occurred in the Microsoft .NET Framework while trying to load assembly id 1. The server may be running out of resources, or the assembly may not be trusted with PERMISSION_SET = EXTERNAL_ACCESS or UNSAFE. Run the query again, or check documentation to see how to solve the assembly trust issues. For more information about this error: 
System.IO.FileNotFoundException: Could not load file or assembly 'microsoft.sqlserver.types, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: 
at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)

at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
--- End of inner exception stack trace ---
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at System.Data.Entity.Internal.InternalContext.SaveChanges()
--- End of inner exception stack trace ---
at System.Data.Entity.Internal.InternalContext.SaveChanges()
at ...

我尝试引用 microsoft.sqlserver.types, Version=11.0.0.0 但没有成功。

找不到与此问题相关的任何问题。有人有这个问题吗?有什么解决办法吗? Azure 发生了什么事,导致它今天无法正常工作。 谢谢。

最佳答案

找到解决方案:

http://www.microsoft.com/en-us/download/details.aspx?id=29065 安装“Microsoft® SQL Server® 2012 的 Microsoft® 系统 CLR 类型”作为启动任务。

复制项目中Startup文件夹中的SQLSysClrTypes.msi,并在同一文件夹中创建startup.cmd文件。注意:应该是“复制到输出目录”=“始终复制”

ServiceDefenition.csdef

...
<Startup>
    <Task commandLine="Startup\Startup.cmd" executionContext="elevated" taskType="simple" />      
</Startup>
...

启动.cmd

REM Install Sql Sys Clr Types

cd /d "%~dp0"

start /w msiexec /i SQLSysClrTypes.msi /qn

现在可以使用了。

希望这可以为某人节省时间。快乐编码...

关于Azure Geomentry 类型引发异常无法加载文件或程序集 microsoft.sqlserver.types,版本=11.0.0.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15953788/

相关文章:

c# - 在应用服务上运行简单的 WebJob

azure - 使用托管标识进行 Blob 存储的 API 连接

android - 获取文件未找到异常

java - 出现 "SQL command not properly ended"错误

android - SQLiteOpenHelper onCreate()/onUpgrade() 何时运行?

java.sql.SQLException 关闭语句

c# - 如何在 C# Windows 应用程序中使用 azure 命令调用 PowerShell 脚本

java - 如何在 HDInsight 中将外部 jar 添加到 Spark?

asp.net - ASP.NET 中的 C++/CLI 组件出现 "module could not be found"错误

python - 我无法获取文件夹的大小