gpt4 book ai didi

asp.net - 更新到 Asp.Net MVC 4 RTM 后无法加载类型 HttpControllerConfigurationAttribute

转载 作者:行者123 更新时间:2023-12-02 18:30:16 24 4
gpt4 key购买 nike

我最初正在使用 ASP.Net MVC 4 Beta 和 EF 4.3.1 开发单页应用程序。我更新了 MVC 4 和 EF 5 的所有 NuGet 包。现在,每当我调用 ApiController 或 DbDataController 时,都会出现以下异常:

无法从程序集“System.Web.Http,Version=4.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”加载类型“System.Web.Http.Controllers.HttpControllerConfigurationAttribute”。

at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Boolean inherit)
at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)
at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)
at System.Web.Http.Controllers.HttpControllerDescriptor.InvokeAttributesOnControllerType(HttpControllerDescriptor controllerDescriptor, Type type)
at System.Web.Http.Controllers.HttpControllerDescriptor..ctor(HttpConfiguration configuration, String controllerName, Type controllerType)
at System.Web.Http.Dispatcher.DefaultHttpControllerSelector.InitializeControllerInfoCache()
at System.Lazy`1.CreateValue()

根据 MVC 4 发行说明,HttpControllerConfigurationAttribute 已被删除,但这并不是说我明确地使用了它。

Per controller configuration: ASP.NET Web API controllers can be attributed with a custom attribute that implements IControllerConfiguration to setup their own formatters, action selector and parameter binders. The HttpControllerConfigurationAttribute has been removed. MVC 4 Release Notes

我的问题是此时可能尝试加载此类型的是什么?

编辑:我现在认为这是因为自 MVC 4 Beta 以来 SPA 位尚未更新,并且其中存在 Controller 配置属性。

最佳答案

每个 Controller 配置:ASP.NET Web API Controller 可以使用实现 IControllerConfiguration 的自定义属性来设置自己的格式化程序、操作选择器和参数绑定(bind)器。 HttpControllerConfigurationAttribute 已被删除。 MVC 4 发行说明

关于asp.net - 更新到 Asp.Net MVC 4 RTM 后无法加载类型 HttpControllerConfigurationAttribute,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12150082/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com