【问题标题】:Webservice keeps referencing to old version of entityframeworkWebservice 一直引用旧版本的 entityframework
【发布时间】:2014-02-04 07:17:22
【问题描述】:

我有一个 .NET 4.5 WCF 网络服务,它使用 Entityframwork 5.0.0 和 MySQL 连接器 6.7.4。 Web 服务在 localhost 上运行良好(即使从另一台计算机上使用),但是当我将其上传到服务器 (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>

有什么想法吗?

【问题讨论】:

  • 你是否检查了应用程序池,与网站名称相关联的 .net 框架版本。

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


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    一些行动建议:

    • 手动从服务器中删除旧版本。

    • 确认您确实发布了新版本的服务。

    • 验证服务器上的实际端点(IP、端口)是否绑定到特定服务。

    • 使用tool(如 ILDASM.exe)检查所有引用,包括所有引用的 dll 引用。

    希望我能帮上忙!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-11
      • 2013-11-26
      • 2012-12-15
      • 1970-01-01
      • 2022-01-23
      • 1970-01-01
      相关资源
      最近更新 更多