getting Access Violation when trying to use injected IActionContextAccessor in tag helper

0

I need to access the UrlHelper through IUrlHelperFactory and IUrlHelperFactory needs ActionContext. I register both, but it results in IIS quitting with "Access Violation" message.

IServiceCollection:

.AddSingleton<IActionContextAccessor, ActionContextAccessor>()
.AddSingleton<IUrlHelperFactory, UrlHelperFactory>();

Tag Helper:

private readonly IUrlHelper _url;

public ServiceIconTagHelper(IUrlHelperFactory url, IActionContextAccessor context)
{
    _url = url.GetUrlHelper(context.ActionContext);
}

Output exception: The program '[1624] iisexpress.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.

c#
asp.net-core
asked on Stack Overflow Apr 14, 2020 by Stein The Ruler • edited Apr 14, 2020 by Stein The Ruler

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0