带有Entity Framework 6.0的WCF错误“底层连接已关闭:连接意外关闭”

时间:2013-11-29 22:15:20

标签: c# asp.net-mvc wcf entity-framework entity-framework-6

我已将.NET 4和EF 4的代码示例从here升级到最新的.Net Framework和EF。我可以在将其升级到.NET 4.5之后使其工作,但无法进一步升级到EF6.0。

在升级到EF6之后,只需要修改一些地方,例如将“using System.Data.Objects”替换为“using System.Data.Entity.Core.Objects”,以便通过编译器。但问题是执行应用程序时会抛出异常。我相信WCF和EF6之间的通信存在问题。这不是超时问题。

异常类型是“System.ServiceModel.CommunicationException,System.ServiceModel,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089”和“System.Net.WebException,System,Version = 4.0.0.0,Culture =中性,PublicKeyToken = b77a5c561934e089“。

堆栈跟踪是 -

System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
**GH.Northwind.Business.Interfaces.INorthwindSvr.GetProducts()
GH.Northwind.Web.Controllers.NorthwindController.AllProducts(AllProductsModel allProductsModel)
lambda_method(Closure , ControllerBase , Object[] )**
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12()
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)
System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass15.<>c__DisplayClass17.<InvokeActionMethodWithFilters>b__14()
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
System.Web.Mvc.Controller.ExecuteCore()
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)
System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5()
System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0()
System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _)
System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End()
System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d()
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f)
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action)
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
System.Web.HttpApplication.ApplicationStepManager.ResumeSteps(Exception error)
System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
System.Web.HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
Microsoft.VisualStudio.WebHost.Request.Process()
Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Connection conn)

我用谷歌搜索但找不到解决方案。 Microsoft服务跟踪工具对大量信息没有帮助。

如果有人可以提供帮助,我感激不尽。

由于

1 个答案:

答案 0 :(得分:0)

看起来OData相关组件也需要升级(See this link)。