locked
Cannot find Iplugin interface in a .net 5 web site is it broken RRS feed

  • Question

  • User-183185495 posted

    I am trying to use the https://github.com/natemcmaster/DotNetCorePlugins in a .net 5 website however I cannot seem to get the Iplugin Reference to be found is this located in another assembley I am using the example code Should I revert back to .net core 3.1 maybe its a braking change in 5 first version?

    public class Program
    {
    public static void Main(string[] args)
    {
        var loaders = new List<PluginLoader>();
    
        // create plugin loaders
        var pluginsDir = Path.Combine(AppContext.BaseDirectory, "plugins");
        foreach (var dir in Directory.GetDirectories(pluginsDir))
        {
            var dirName = Path.GetFileName(dir);
            var pluginDll = Path.Combine(dir, dirName + ".dll");
            if (File.Exists(pluginDll))
            {
                var loader = PluginLoader.CreateFromAssemblyFile(
                    pluginDll,
                    sharedTypes: new [] { typeof(IPlugin) });
                loaders.Add(loader);
            }
        }
    
        // Create an instance of plugin types
        foreach (var loader in loaders)
        {
            foreach (var pluginType in loader
                .LoadDefaultAssembly()
                .GetTypes()
                .Where(t => typeof(IPlugin).IsAssignableFrom(t) && !t.IsAbstract))
            {
                // This assumes the implementation of IPlugin has a parameterless constructor
                IPlugin plugin = (IPlugin)Activator.CreateInstance(pluginType);
    
                Console.WriteLine($"Created plugin instance '{plugin.GetName()}'.");
            }
        }
     }

    It cannot resolve the Iplugin interface is their a reason for this 

    Friday, December 4, 2020 11:43 AM

All replies

  • User475983607 posted

    According to the linked documentation, you were supposed to create an IPlugin interface and implementation.  I recommend contacting the project owner if you have questions about using the project.  Secondly, the code is open so you can just read the code.

    The Hello World Example is here...

    https://github.com/natemcmaster/DotNetCorePlugins/tree/main/samples/hello-world

    Friday, December 4, 2020 12:39 PM
  • User-183185495 posted

    I have used the hello world example I am using the hello world mvc example and I cannot get it to work just sent a request to his github it may not be comptable with .net 5 yet

    According to the linked documentation, you were supposed to create an IPlugin interface and implementation.  I recommend contacting the project owner if you have questions about using the project.  Secondly, the code is open so you can just read the code.

    The Hello World Example is here...

    https://github.com/natemcmaster/DotNetCorePlugins/tree/main/samples/hello-world

    Friday, December 4, 2020 12:47 PM
  • User475983607 posted

    I have used the hello world example I am using the hello world mvc example and I cannot get it to work just sent a request to his github it may not be comptable with .net 5 yet

    The project clearly and openly support .netstandard 2.0.  Why do you think it is not compatible?  What exactly is the error?

    Friday, December 4, 2020 12:52 PM
  • User-183185495 posted

    The view is not presented to the user even though you go to the MyPlugin controller action it generated the two dlls one for the controller and second for views I placed them in the plugins folder in a sep folder as directed but its still not discovering them which is odd no error the view is just not present the view is simple and simply puts a test string to the user

    roguenidb

    I have used the hello world example I am using the hello world mvc example and I cannot get it to work just sent a request to his github it may not be comptable with .net 5 yet

    The project clearly and openly support .netstandard 2.0.  Why do you think it is not compatible?  What exactly is the error?

    Friday, December 4, 2020 12:54 PM
  • User-474980206 posted

    While the plug-in infrastructure is .netstandard, the asp.net core sample startup code is for asp.net core 2.1, you probably have to update this code to use 3.1 or greater. Especially if using endpoint routing.

    Friday, December 4, 2020 7:05 PM