Search code examples
asp.net.netrazordependency-injection.net-5

ResourceManager not being instantiated by DI in ASP.NET Core Razor Pages


I have a large and complicated solution with 30+ projects, that I'm migrating from ASP.NET MVC 4.72 to ASP.NET Core 5.

When the Home/Index view is being returned, something goes wrong way down in Microsoft's RazorPagePropertyActivator.cs class.

The red box contains the _propertyActivators array, which contains the page's properties.

The green box contains PropertyInfo value for the first 3 values of that array.

Note that the first 2 properties (obscured because the full class names reveal company data) list proper types for FeatureFlag and CssViewHelper properties. However, the third value (within the light blue box) maps ResourceManager to System.Object.

The Exception shown in the yellow box, is what happens when the DI system tries to provide a concrete instantiated class for ResourceManager.

enter image description here

Does anybody know why ASP.NET Core would try to provide System.Object as the class for ResourceManager? I can find nothing in our code that would account for it. I'm open to any and all crazy ideas or suggestions for areas of investigation at this point!


Solution

  • I narrowed down the issue to my attempt to inject a dynamic object in _ViewImports.cshtml.

    I have followed up with a more specific question, here: ASP.NET Core 5 How to Inject Dynamic Typed Object in _ViewImports.cshtml