UPDATE 10:29 MST on 11/7
Oddly enough, if I transfer the attribute from the folder ComponentModelback to the root of the project Common, the code works fine. I can’t imagine what may have referred to the old namespace after all the links have been reorganized for the namespace InflowHealth.Common.ComponentModel.
It almost seems like some kind of link is hiding somewhere, not based on code, but rather the runtime and dynamic, but I don’t see it, looking through all the search results InflowHealthErrorContext.
UPDATE 19:33 MST on 11/6
A new interest, when I commented out a line to use a custom attribute to inherit routes and use the default value, it exploded anyway. Of additional interest, the namespace he is looking InflowHealth.Common.InflowHealthErrorContextAttribute for is actually the old FQN before I processed it and moved it to the folder (and namespace) ComponentModel.
UPDATE 07:42 MST on 11/6
I believe that I have determined that the problem is related to another custom attribute that I use to inherit actions. This attribute is added to HttpConfigurationas follows:
public static void MapInheritedAttributeRoutes(this HttpConfiguration config)
{
config.MapHttpAttributeRoutes(new InheritanceDirectRouteProvider());
}
The implementation of this attribute is quite simple:
public class InheritanceDirectRouteProvider : DefaultDirectRouteProvider
{
protected override IReadOnlyList<IDirectRouteFactory> GetActionRouteFactories(HttpActionDescriptor actionDescriptor)
{
return actionDescriptor.GetCustomAttributes<IDirectRouteFactory>(true);
}
}
It seems that inheriting this attribute InflowHealthErrorContextis causing problems, but I don’t know exactly what the problem is. I tried:
- Removal
Inherited = falseso that it is inherited. AllowMultiple = true , .
.
Common, Web API. , , .
Fusion , .
Attribute:
using System;
namespace InflowHealth.Common.ComponentModel
{
[AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = true)]
public sealed class InflowHealthErrorContextAttribute : Attribute
{
public InflowHealthErrorContextAttribute(string errorContext)
{
ErrorContext = errorContext;
}
public string ErrorContext { get; }
}
}
, :
[Authorize(Roles = Roles.ALL_ADMINS)]
[Route("api/ControlPanelApi/PayerClassifications")]
[InflowHealthErrorContext("Error getting payer classifications.")]
public IHttpActionResult GetPayerClassifications(int clientId, bool showAllRows)
{
return Ok(GetData(payerClassificationManager, clientId, showAllRows));
}
-API . , :
GlobalConfiguration.Configure(WebApiConfig.Register);
:
'InflowHealth.Common.InflowHealthErrorContextAttribute' 'InflowHealth.Common, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = null'.
:
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(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)
at System.Reflection.RuntimeMethodInfo.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Attribute.GetCustomAttributes(MemberInfo element, Type type, Boolean inherit)
at System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, Boolean inherit)
at System.Reflection.CustomAttributeExtensions.GetCustomAttribute[T](MemberInfo element)
at System.Web.Http.Controllers.ApiControllerActionSelector.ActionSelectorCacheItem.IsValidActionMethod(MethodInfo methodInfo)
at System.Array.FindAll[T](T[] array, Predicate`1 match)
at System.Web.Http.Controllers.ApiControllerActionSelector.ActionSelectorCacheItem..ctor(HttpControllerDescriptor controllerDescriptor)
at System.Web.Http.Controllers.ApiControllerActionSelector.GetInternalSelector(HttpControllerDescriptor controllerDescriptor)
at System.Web.Http.Controllers.ApiControllerActionSelector.GetActionMapping(HttpControllerDescriptor controllerDescriptor)
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)
at System.Web.Http.Routing.AttributeRoutingMapper.<>c__DisplayClass2.<MapAttributeRoutes>b__0(HttpConfiguration config)
at System.Web.Http.HttpConfiguration.EnsureInitialized()
at System.Web.Http.GlobalConfiguration.Configure(Action`1 configurationCallback)
at InflowHealthPortal.MvcApplication.Application_Start() in Global.asax.cs:line 22