Breeze.js WebApi 2启动问题

时间:2014-08-29 17:10:34

标签: asp.net-web-api breeze

我尝试使用breeze.js服务器端asp.net web api 2进行基本设置。我有微风路由设置和微风注释的web api控制器。调用元数据操作(或任何针对该问题的操作)会在下面引发此错误。就我所知,它与我实体上的延迟加载导航属性无关。

这个错误似乎是一个懒惰的类型,也许是微风数据结构的内部?我引用了Breeze.WebApi2和Breeze.ContextProvider v1.4以及Breeze.ContextProvider.EF6

我根据breeze文档在我的数据库上下文中显式禁用了延迟加载。 dbContext.Configuration.LazyLoadingEnabled = false;
dbContext.Configuration.ProxyCreationEnabled = false;

感谢。

   ValueFactory attempted to access the Value property of this instance.","ExceptionType":"System.InvalidOperationException","StackTrace":"   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at System.Lazy`1.get_Value()
   at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.GetControllerMapping()   at System.Web.Http.Routing.AttributeRoutingMapper.AddRouteEntries(SubRouteCollection collector, HttpConfiguration configuration, IInlineConstraintResolver constraintResolver, IDirectRouteProvider directRouteProvider)
   at System.Web.Http.Routing.AttributeRoutingMapper.<>c__DisplayClass2.<>c__DisplayClass4.<MapAttributeRoutes>b__1()
  at System.Web.Http.Routing.RouteCollectionRoute.EnsureInitialized(Func`1 initializer)\r\n   at System.Web.Http.Routing.AttributeRoutingMapper.<>c__DisplayClass2.<MapAttributeRoutes>b__0(HttpConfiguration config)
   at System.Web.Http.HttpConfiguration.ApplyControllerSettings(HttpControllerSettings settings, HttpConfiguration configuration)
   at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)
   at System.Web.Http.Controllers.HttpControllerDescriptor.Initialize()
   at System.Web.Http.Controllers.HttpControllerDescriptor..ctor(HttpConfiguration configuration, String controllerName, Type controllerType)
   at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.InitializeControllerInfoCache()\r\n   at System.Lazy`1.CreateValue()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Lazy`1.get_Value()
   at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.SelectController(HttpRequestMessage request)
   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"}

1 个答案:

答案 0 :(得分:1)

事实证明这是路线注册顺序的事情。我删除了由Breeze nuget安装添加的webactivor.PreApplicationStartMethod()程序集指令,并在配置的标准Web api路由之后手动调用Global.asax中的Breeze路由配置并开始工作。之前设置似乎会导致问题。