【问题标题】:Breeze.js WebApi 2 Startup IssueBreeze.js WebApi 2 启动问题
【发布时间】:2015-03-30 09:24:59
【问题描述】:

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

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

根据微风文档,我已在我的数据库上下文中明确禁用延迟加载。 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()"}

【问题讨论】:

    标签: asp.net-web-api breeze


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2013-02-25
      • 2017-12-17
      • 1970-01-01
      • 2021-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-11
      • 2015-10-21
      相关资源
      最近更新 更多