System.InvalidOperationException when including the NuGet package for web support

,

Problem

If only the combit.ListLabel??.Web NuGet package is added to an ASP.NET/MVC project from .NET 6 and the application is started afterwards, a System.InvalidOperationException can occur because of a missing AuthorizationPolicy.

System.InvalidOperationException: The AuthorizationPolicy named: 'AuthorizationMode' was not found.

Solution

The reason is that the web assembly contains some controllers that need this policy. To solve the problem the call builder.Services.AddWebReportDesigner() must be added to the Program.cs file. This call will then add the required policy. If the application uses a Startup.cs file instead, the call must be added in the ConfigureServices function.

1 Like