MEF No exports were found that match the constraint

Hi, i'm trying to implement MEF in my WPF app, however i'm getting this error, not sure why anymore. Everything looks correct for me

This is my plugin:
public interface IPlugin
{
    void Process();
    string Name { get; }
    string Description { get; }
}

[Export(typeof(IPlugin))]
public class Plugin : IPlugin
{
    public string Name => "Plugin";
    public string Description => "Plugin";

    public void Process()
    {
        Console.WriteLine("Plugin");
    }
}



and this is part of my WPF App.xaml.cs

public interface IPlugin
{
    void Process();
    string Name { get; }
    string Description { get; }
}

public partial class App : Application
{
    [Import(typeof(IPlugin))]
    public IPlugin plugin;

    protected override void OnStartup(StartupEventArgs e)
    {
        base.OnStartup(e);

        string plugins = System.IO.Path.Combine(
            Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
            "WPFAPP", "plugins");

        if (!Directory.Exists(plugins))
        {
            Directory.CreateDirectory(plugins);
        }

        var catalog = new DirectoryCatalog(plugins);

        try
        {
            var container = new CompositionContainer(catalog);
            container.ComposeParts(this);
        }
        catch (Exception ex)
        {
            Console.WriteLine($"ex: {ex}");
        }
    }
}


is there something wrong?
Was this page helpful?