ASP.NET Core and View conflict resolution

Sergey Isupov 96 Reputation points
2021-11-11T06:54:44.943+00:00

I'm trying to build a plugin system for ASP.NET Core application. I have a folder inside the app called 'Plugins'.

In general, a plugin looks like a folder containing two files: Plugin.dll and Plugin.Views.dll The app scans this folder and loads these assemblies

foreach (var ext in extensionManager.Extensions)
    {
        mvcBuilder.AddApplicationPart(ext.Assembly);
        if (ext.ViewsAssembly != null)
        {
            mvcBuilder.AddApplicationPart(ext.ViewsAssembly);
        }
    }

If these plugins have ViewComponents with the same name I get an error. Model from Plugin1 may be passed into Plugin2's Razor View.

The model item passed into the ViewDataDictionary is of type 'Plugin1.Models.MyModel', 
but this ViewDataDictionary instance requires a model item of type 'Plugin2.Models.MyModel'
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
2,547 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
6,959 questions
{count} votes

0 additional answers

Sort by: Most helpful