c# - Web 服务不断引用旧版本的 Entity Framework

标签 c# mysql wcf web-services entity-framework

我有一个 .NET 4.5 WCF 网络服务,它使用 Entityframwork 5.0.0 和 MySQL 连接器 6.7.4。 Web 服务在本地主机上运行良好(即使从另一台计算机使用),但是当我将它上传到服务器 (IIS) 时,我在尝试使用 Web 服务时遇到以下错误:

»Could not load file or assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.«

我找不到任何提到 EF 4.4.0.0 的地方。


堆栈跟踪:

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent"><System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">><EventID>131076</EventID><Type>3</Type><SubType Name="Error">0</SubType><Level>2</Level><TimeCreated SystemTime="2014-01-15T10:10:45.9384169Z" /><Source Name="System.ServiceModel" /><Correlation ActivityID="{2db07ea1-945c-4f1b-bd7b-c89c7f34b7d4}" /><Execution ProcessName="w3wp" ProcessID="5772" ThreadID="3" /><Channel /><Computer>SVIZEC</Computer></System><ApplicationData><TraceData><DataItem><TraceRecord Severity="Error" Channel="Operational" xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord"><TraceIdentifier>http://msdn.microsoft.com/sl-SI/library/System.ServiceModel.Diagnostics.TraceHandledException.aspx</TraceIdentifier><Description>Handling an exception. Exception details: System.InvalidOperationException: Failed to set Database.DefaultConnectionFactory to an instance of the 'MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity' type as specified in the application configuration. See inner exception for details. ---&gt; System.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&amp; stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
   at System.Type.GetType(String typeName, Boolean throwOnError)
   at System.Data.Entity.Internal.ConfigFile.DefaultConnectionFactoryElement.GetFactoryType()
   at System.Data.Entity.Internal.AppConfig.&lt;.ctor&gt;b__1()
   --- End of inner exception stack trace ---
   at System.Data.Entity.Internal.AppConfig.&lt;.ctor&gt;b__1()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
   at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity)
  at System.Data.Entity.DbSet`1.Add(TEntity entity)
   at UniFeriBank_Webservice.Database.Dao.DebitCardDao.Create() in d:\Študenti\1314\SOA\Projekt\banka2\UniFeriBank_Webservice\Database\Dao\DebitCardDao.cs:line 121
   at UniFeriBank_Webservice.Service.InvoiceService.Create() in d:\Študenti\1314\SOA\Projekt\banka2\UniFeriBank_Webservice\Service\InvoiceService.cs:line 266
   at UniFeriBank_Webservice.UniFeriBankService.CreateDB() in d:\Študenti\1314\SOA\Projekt\banka2\UniFeriBank_Webservice\UniFeriBankService.cs:line 121
   at SyncInvokeCreateDB(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp; outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</Description><AppDomain>/LM/W3SVC/1/ROOT/SOATravel/test-2-130342542452822131</AppDomain><Exception><ExceptionType>System.InvalidOperationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Failed to set Database.DefaultConnectionFactory to an instance of the 'MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity' type as specified in the application configuration. See inner exception for details.</Message><StackTrace>   at System.Data.Entity.Internal.AppConfig.&amp;lt;.ctor&amp;gt;b__1()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
   at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity)
   at System.Data.Entity.DbSet`1.Add(TEntity entity)
   at UniFeriBank_Webservice.Database.Dao.DebitCardDao.Create() in d:\Študenti\1314\SOA\Projekt\banka2\UniFeriBank_Webservice\Database\Dao\DebitCardDao.cs:line 121
   at UniFeriBank_Webservice.Service.InvoiceService.Create() in d:\Študenti\1314\SOA\Projekt\banka2\UniFeriBank_Webservice\Service\InvoiceService.cs:line 266
   at UniFeriBank_Webservice.UniFeriBankService.CreateDB() in d:\Študenti\1314\SOA\Projekt\banka2\UniFeriBank_Webservice\UniFeriBankService.cs:line 121
   at SyncInvokeCreateDB(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp;amp; outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</StackTrace><ExceptionString>System.InvalidOperationException: Failed to set Database.DefaultConnectionFactory to an instance of the 'MySql.Data.Entity.MySqlConnectionFactory, MySql.Data.Entity' type as specified in the application configuration. See inner exception for details. ---&amp;gt; System.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&amp;amp; stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
   at System.Type.GetType(String typeName, Boolean throwOnError)
   at System.Data.Entity.Internal.ConfigFile.DefaultConnectionFactoryElement.GetFactoryType()
   at System.Data.Entity.Internal.AppConfig.&amp;lt;.ctor&amp;gt;b__1()
   --- End of inner exception stack trace ---
   at System.Data.Entity.Internal.AppConfig.&amp;lt;.ctor&amp;gt;b__1()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
   at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
   at System.Data.Entity.Internal.Linq.InternalSet`1.ActOnSet(Action action, EntityState newState, Object entity, String methodName)
   at System.Data.Entity.Internal.Linq.InternalSet`1.Add(Object entity)
   at System.Data.Entity.DbSet`1.Add(TEntity entity)
   at UniFeriBank_Webservice.Database.Dao.DebitCardDao.Create() in d:\Študenti\1314\SOA\Projekt\banka2\UniFeriBank_Webservice\Database\Dao\DebitCardDao.cs:line 121
   at UniFeriBank_Webservice.Service.InvoiceService.Create() in d:\Študenti\1314\SOA\Projekt\banka2\UniFeriBank_Webservice\Service\InvoiceService.cs:line 266
   at UniFeriBank_Webservice.UniFeriBankService.CreateDB() in d:\Študenti\1314\SOA\Projekt\banka2\UniFeriBank_Webservice\UniFeriBankService.cs:line 121
   at SyncInvokeCreateDB(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp;amp; outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp;amp; rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)</ExceptionString><InnerException><Exception><ExceptionType>System.IO.FileLoadException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType><Message>Could not load file or assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)</Message><StackTrace>   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&amp;amp; stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
   at System.Type.GetType(String typeName, Boolean throwOnError)
   at System.Data.Entity.Internal.ConfigFile.DefaultConnectionFactoryElement.GetFactoryType()
   at System.Data.Entity.Internal.AppConfig.&amp;lt;.ctor&amp;gt;b__1()</StackTrace><ExceptionString>System.IO.FileLoadException: Could not load file or assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type)
   at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&amp;amp; stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName)
   at System.Type.GetType(String typeName, Boolean throwOnError)
   at System.Data.Entity.Internal.ConfigFile.DefaultConnectionFactoryElement.GetFactoryType()
   at System.Data.Entity.Internal.AppConfig.&amp;lt;.ctor&amp;gt;b__1()

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
</ExceptionString></Exception></InnerException></Exception></TraceRecord></DataItem></TraceData></ApplicationData></E2ETraceEvent>

有什么想法吗?

最佳答案

我通常用 ILDASM.exe 打开所有的 .dll 和 .exe 文件,然后手动检查 MANIFEST。

关于c# - Web 服务不断引用旧版本的 Entity Framework ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21143889/

相关文章:

mysql - 访问 cakephp3 Controller 中的非关联表

未处理 WCF MSMQ 消息队列

asp.net - 无法加载类型 'System.ServiceModel.Activation.HttpHandler'与WCF REST的版本冲突

c# - 动态连接/基于表达式的连接字符串 SSRS

c# - 在 XAML 中绑定(bind) UserControl 的 DataContext 不起作用(Windows Phone)

c# - 一个可以分解三元表达式的工具

php - 我可以在 PHP 中混合使用 MySQL API 吗?

mysql - 防止多对多连接表在与 self 连接时出现重复的规范方法

c# - 将 json 响应转换为数据表

jquery+wcf。基本身份验证问题