Where is the `AspNetCore.CacheOutput.Extensions` namespace and `UseCacheOutput`?
After migrating to 2.x the namespace is gone and now I get an error when launching the application:
Application startup exception
Unhandled exception. System.ArgumentException: cacheKeyGeneratorType
at AspNetCore.CacheOutput.InvalidateCacheOutputAttribute..ctor(Type controllerType, String methodName, Type cacheKeyGeneratorType)
at AspNetCore.CacheOutput.InvalidateCacheOutputAttribute..ctor(String methodName, Type cacheKeyGeneratorType)
at System.Reflection.CustomAttribute._CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)
at System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule module, RuntimeType type, IRuntimeMethodInfo ctor, IntPtr& blob, IntPtr blobEnd, Int32& namedArgs)
at System.Reflection.CustomAttribute.AddCustomAttributes(ListBuilder`1& attributes, RuntimeModule decoratedModule, Int32 decoratedMetadataToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, ListBuilder`1 derivedAttributes)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeMethodInfo method, RuntimeType caType, Boolean inherit)
at System.Reflection.RuntimeMethodInfo.GetCustomAttributes(Boolean inherit)
at Microsoft.AspNetCore.Mvc.ApplicationModels.DefaultApplicationModelProvider.CreateActionModel(TypeInfo typeInfo, MethodInfo methodInfo)
at Microsoft.AspNetCore.Mvc.ApplicationModels.DefaultApplicationModelProvider.OnProvidersExecuting(ApplicationModelProviderContext context)
at Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModelFactory.CreateApplicationModel(IEnumerable`1 controllerTypes)
at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.GetDescriptors()
at Microsoft.AspNetCore.Mvc.ApplicationModels.ControllerActionDescriptorProvider.OnProvidersExecuting(ActionDescriptorProviderContext context)
at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.UpdateCollection()
at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.Initialize()
at Microsoft.AspNetCore.Mvc.Infrastructure.DefaultActionDescriptorCollectionProvider.GetChangeToken()
at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.<>c__DisplayClass11_0.<Subscribe>b__0()
at Microsoft.Extensions.Primitives.ChangeToken.OnChange(Func`1 changeTokenProducer, Action changeTokenConsumer)
at Microsoft.AspNetCore.Mvc.Routing.ActionEndpointDataSourceBase.Subscribe()
at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageActionEndpointDataSource..ctor(PageActionEndpointDataSourceIdProvider dataSourceIdProvider, IActionDescriptorCollectionProvider actions, ActionEndpointFactory endpointFactory, OrderedEndpointsSequenceProvider orderedEndpoints)
at Microsoft.AspNetCore.Builder.RazorPagesEndpointRouteBuilderExtensions.GetOrCreateDataSource(IEndpointRouteBuilder endpoints)
at Microsoft.AspNetCore.Builder.RazorPagesEndpointRouteBuilderExtensions.MapRazorPages(IEndpointRouteBuilder endpoints)
at OdhApiCore.Startup.<>c.<Configure>b__8_3(IEndpointRouteBuilder endpoints) in C:\Workspace\noi\code\odh-api-core\OdhApiCore\Startup.cs:line 483
at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action`1 configure)
at OdhApiCore.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in C:\Workspace\noi\code\odh-api-core\OdhApiCore\Startup.cs:line 481
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass15_0.<UseStartup>b__1(IApplicationBuilder app)
at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
at OdhApiCore.Program.Main(String[] args) in C:\Workspace\noi\code\odh-api-core\OdhApiCore\Program.cs:line 12
at OdhApiCore.Program.<Main>(String[] args)
Am I missing something?
@toburger AspNetCore.CacheOutput.Extensions and UseCacheOutput were deprecated. It should work, just remove them.
When I remove it I get the error message from above. So I guess I'm missing something. I've registered a custom cache key generator, but as far I'm understanding it should nevertheless use the default key generator if it doesn't find a custom one.
I try to provide a minimal repro. The project I'm getting the error is quite big and maybe there are some issues with the order the dependencies get called.
Found it:
[InvalidateCacheOutput(nameof(Get), typeof(WeatherForecastController))]
public void Invalidate()
{
}
When I specify the InvalidateCacheOutput with the typeof() parameter (to refer to another controller) the error gets thrown.
My bad, I see now, that the parameter order has to be switched! Now everything works!