2014-08-29 66 views
0

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

这个错误似乎是微风数据结构内部的懒惰类型?我引用了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

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