【问题标题】:WCF with Entity Framework 6.0 error "The underlying connection was closed: The connection was closed unexpectedly"WCF 与实体框架 6.0 错误“基础连接已关闭:连接已意外关闭”
【发布时间】:2013-11-29 22:15:19
【问题描述】:

我已将 .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 服务跟踪工具无法提供太多信息。

如果有人能提供帮助,我将不胜感激。

谢谢

【问题讨论】:

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


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-16
    • 1970-01-01
    • 1970-01-01
    • 2013-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-08
    相关资源
    最近更新 更多