_read_only_
_read_only_
CC#
Created by _read_only_ on 4/27/2024 in #help
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");
}
}
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}");
}
}
}
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?
12 replies
CC#
Created by _read_only_ on 4/26/2024 in #help
"Protected" dll reference
Hi all I'm developing open-sourced WPF app, unfortunately there is already competitiors that have similar app - I want to have some sort of unique features that will be developed in "protected" dll that my wpf app will reference and use. But not sure about some of the questions below: 1) How can I develop such code, that it will still compile for people that are trying to use source code (I'm fine with just not having such functionalities in compiled apps) 2) How can i "protect" such dll? Is .net reactor good? Virtualization? (Also I'm fine with it being obfuscated, I know it only slows down people, as long as its not available for copy paste its good)
34 replies