使用实体模型框架访问MySql数据库的已部署C#应用程序出现异常

使用实体模型框架访问MySql数据库的已部署C#应用程序出现异常,c#,mysql,.net,entity-framework,C#,Mysql,.net,Entity Framework,我发现自己对最近在部署的应用程序中看到的行为扭曲一无所知 我有一个C#应用程序,使用实体模型framework 5和.net framework 4.5 应用程序访问远程Mysql数据库,为此,我们使用MySqlConnector版本6.9.7 几个月来,一切都很正常,直到上周,应用程序部署到的机器在尝试更新数据库时开始抛出异常 以下是异常的堆栈跟踪: 2016-06-08 16:38:51247[1]错误CactusLogger-错误!写入数据库失败!-例外信息 System.TypeIni

我发现自己对最近在部署的应用程序中看到的行为扭曲一无所知

我有一个C#应用程序,使用实体模型framework 5和.net framework 4.5

应用程序访问远程Mysql数据库,为此,我们使用MySqlConnector版本6.9.7

几个月来,一切都很正常,直到上周,应用程序部署到的机器在尝试更新数据库时开始抛出异常

以下是异常的堆栈跟踪:


2016-06-08 16:38:51247[1]错误CactusLogger-错误!写入数据库失败!-例外信息
System.TypeInitializationException:“ExtentPlaceholderCreator”的类型初始值设定项引发异常。-->System.Reflection.TargetInvocationException:调用的目标已引发异常。-->System.DllNotFoundException:无法加载DLL“SqlServerSpatial110.DLL”:找不到指定的模块。(来自HRESULT的异常:0x8007007E)
位于Microsoft.SqlServer.Types.GLNativeMethods.SetClrFeatureSwitchMap(Int32 clrFeatureSwitchMap)
在Microsoft.SqlServer.Types.SqlGeometry.IsValidExpensive()中
位于Microsoft.SqlServer.Types.SqlGeometry.Construct(geodatag,int32srid)
位于Microsoft.SqlServer.Types.SqlGeometry.GeometryFromText(OpenGisType类型、SqlChars文本、Int32 srid)
位于Microsoft.SqlServer.Types.SqlGeometry.stgeometrfromtext(SqlChars geometryTaggedText,Int32 srid)
位于Microsoft.SqlServer.Types.SqlGeometry.Parse(SqlString s)
---内部异常堆栈跟踪的结束---
位于System.RuntimeMethodHandle.InvokeMethod(对象目标、对象[]参数、签名符号、布尔构造函数)
位于System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(对象obj,对象[]参数,对象[]参数)
在System.Reflection.RuntimeMethodInfo.Invoke(对象obj、BindingFlags invokeAttr、绑定器绑定器、对象[]参数、CultureInfo区域性)
位于System.Data.SqlClient.SqlSpatialServices.GeometryFromText(字符串geometryText)
位于System.Data.Spatial.DbGeometry.FromText(字符串wellKnownText)
位于System.Data.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.InitializeTypeDefaultMap()处
位于System.Data.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator..cctor()处
---内部异常堆栈跟踪的结束---
位于System.Data.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.GetPropagatorResultForPrimitiveType(PrimitiveType PrimitiveType,PropagatorResult&result)
位于System.Data.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.Visite(EdmMember节点)
位于System.Data.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.CreateEntitySetPlaceholder(EntitySet-EntitySet)
位于System.Data.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.CreatePlaceholder(EntitySetBase区段,UpdateTranslator父级)
在System.Data.Mapping.Update.Internal.Propagator.Visit(DbScanExpression节点)
位于System.Data.Common.CommandTrees.DbScanExpression.Accept[TResultType](DbExpressionVisitor`1访问者)
位于System.Data.Mapping.Update.Internal.UpdateExpressionVisitor`1.Visit(DbExpression)
位于System.Data.Mapping.Update.Internal.Propagator.Visite(DbProjectExpression节点)
在System.Data.Common.CommandTrees.DbProjectExpression.Accept[TResultType](DbExpressionVisitor`1访问者)处
位于System.Data.Mapping.Update.Internal.Propagator.Propagate(UpdateTranslator父级、EntitySet表、DbQueryCommandTree umView)
在System.Data.Mapping.Update.Internal.UpdateTranslator.d_u44.MoveNext()中
在System.Linq.Enumerable.d_u58`1.MoveNext()中
位于System.Data.Mapping.Update.Internal.UpdateCommandOrderer..ctor(IEnumerable`1命令,UpdateTranslator转换器)
位于System.Data.Mapping.Update.Internal.UpdateTranslator.ProduceCommands()处
位于System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager,IEntITYAAdapter适配器)
位于System.Data.EntityClient.EntityAdapter.Update(EntityStateManager entityCache)
位于System.Data.Objects.ObjectContext.SaveChanges(保存选项)
位于System.Data.Entity.Internal.InternalContext.SaveChanges()处
在System.Data.Entity.Internal.LazyInternalContext.SaveChanges()中
位于System.Data.Entity.DbContext.SaveChanges()处
在MyApplication.MyForm.AssignBtn_单击(对象发送者,事件参数e)

特别令人沮丧的是,开发机器上没有抛出异常

查看堆栈跟踪很明显,它正在查找SqlServerSpatial110.dll,这是一个我们以前从未引用过的dll。此外,我觉得奇怪的是,堆栈跟踪显示堆栈跟踪显示应用程序正在访问Microsoft.SqlServer.Types,而不是MySql.Data.Types,因为下面的DB和连接器应该是MySql

不用说,我不知道使用任何类型的空间数据类型

目前,我的最佳选择是,在部署的计算机上自动运行的最新Windows更新肯定有一些副作用

任何关于问题根源的提示,或任何可能的解决方案


提前感谢

您的问题是机器找不到
'SqlServerSpatial110.dll'
来加载它,因此我假设您的所有C#控制器都没有正确加载,因为这听起来公平且正确。对我来说,真正的问题是理解为什么突然间找不到“SqlServerSpatial110.dll”:更不用说我甚至不知道应用程序正在寻找它。看这个。我同意@ssanga check的观点,我已经检查了这些问题和答案:让我困惑的是,我没有使用任何类型的“空间”数据类型,无论是在数据库中还是在我的应用程序中。数据库列中仅使用int、varchar、datetime/时间戳和enum。此外,我甚至没有使用SQLServer作为数据库。
2016-06-08 16:38:51,247 [1] ERROR CactusLogger - Error! Writing to Database failed! - Exception Information 
System.TypeInitializationException: The type initializer for 'ExtentPlaceholderCreator' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DllNotFoundException: Unable to load DLL 'SqlServerSpatial110.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Microsoft.SqlServer.Types.GLNativeMethods.SetClrFeatureSwitchMap(Int32 clrFeatureSwitchMap)
at Microsoft.SqlServer.Types.SqlGeometry.IsValidExpensive()
at Microsoft.SqlServer.Types.SqlGeometry.Construct(GeoData g, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeometry.GeometryFromText(OpenGisType type, SqlChars text, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeometry.STGeomFromText(SqlChars geometryTaggedText, Int32 srid)
at Microsoft.SqlServer.Types.SqlGeometry.Parse(SqlString s)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Data.SqlClient.SqlSpatialServices.GeometryFromText(String geometryText)
at System.Data.Spatial.DbGeometry.FromText(String wellKnownText)
at System.Data.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.InitializeTypeDefaultMap()
at System.Data.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator..cctor()
--- End of inner exception stack trace ---
at System.Data.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.GetPropagatorResultForPrimitiveType(PrimitiveType primitiveType, PropagatorResult& result)
at System.Data.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.Visit(EdmMember node)
at System.Data.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.CreateEntitySetPlaceholder(EntitySet entitySet)
at System.Data.Mapping.Update.Internal.Propagator.ExtentPlaceholderCreator.CreatePlaceholder(EntitySetBase extent, UpdateTranslator parent)
at System.Data.Mapping.Update.Internal.Propagator.Visit(DbScanExpression node)
at System.Data.Common.CommandTrees.DbScanExpression.Accept[TResultType](DbExpressionVisitor`1 visitor)
at System.Data.Mapping.Update.Internal.UpdateExpressionVisitor`1.Visit(DbExpression expression)
at System.Data.Mapping.Update.Internal.Propagator.Visit(DbProjectExpression node)
at System.Data.Common.CommandTrees.DbProjectExpression.Accept[TResultType](DbExpressionVisitor`1 visitor)
at System.Data.Mapping.Update.Internal.Propagator.Propagate(UpdateTranslator parent, EntitySet table, DbQueryCommandTree umView)
at System.Data.Mapping.Update.Internal.UpdateTranslator.<ProduceDynamicCommands>d__44.MoveNext()
at System.Linq.Enumerable.<ConcatIterator>d__58`1.MoveNext()
at System.Data.Mapping.Update.Internal.UpdateCommandOrderer..ctor(IEnumerable`1 commands, UpdateTranslator translator)
at System.Data.Mapping.Update.Internal.UpdateTranslator.ProduceCommands()
at System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
at System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
at System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
at System.Data.Entity.Internal.InternalContext.SaveChanges()
at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
at System.Data.Entity.DbContext.SaveChanges()
at MyApplication.MyForm.AssignBtn_Click(Object sender, EventArgs e)