Plugins XSockets插件框架AddLocation

Plugins XSockets插件框架AddLocation,plugins,xsockets.net,Plugins,Xsockets.net,Composable.AddLocation不适用于我,即使加载了dll,我也可以在输出窗口中看到它,但GetExports始终返回null。 我使用了来自 所以这是可行的: Composable.LoadAssembly(Path.Combine(Helper.PluginsDirectory, "testplugin.dll")); 但这并不是: Composable.AddLocation(Helper.PluginsDirectory, SearchOption.AllDirector

Composable.AddLocation不适用于我,即使加载了dll,我也可以在输出窗口中看到它,但GetExports始终返回null。 我使用了来自

所以这是可行的:

Composable.LoadAssembly(Path.Combine(Helper.PluginsDirectory, "testplugin.dll"));
但这并不是:

Composable.AddLocation(Helper.PluginsDirectory, SearchOption.AllDirectories, false);
所有其他代码都是相同的

这里是解决方案:当我删除框架dll和dll中的XSockets插件时,Composable.AddLocation开始工作,它描述了插件目录中的插件接口。

我猜是这样的: 插件框架已经加载了Helper.plugins目录中的文件。 如果两次加载其中一个,将无法获得导出

解决方法

class Program
{
    static void Main(string[] args)
    {
        Composable.RegisterExport<IAnimal>();

        //Helper that fix your issue...  
        Helpers.AddLocation(@"C:\Users\Uffe\Desktop\DynamicAssemblies\Implementation\bin\Debug", SearchOption.AllDirectories);

        Composable.ReCompose();

        var a = Composable.GetExports<IAnimal>();
        foreach (var animal in a)
        {
            animal.Says();
        }

        Console.ReadLine();
    }

}

public static class Helpers
{
    public static void AddLocation(string location, System.IO.SearchOption searchOption)
    {
        foreach (var assembly in Directory.GetFiles(location, "*.dll", searchOption))
        {                
            AssemblyName verifyName = AssemblyName.GetAssemblyName(assembly);                                   
            if(!Composable.LoadedAssemblies.Any(p => p.FullName == verifyName.FullName))  
                Composable.LoadAssembly(assembly);                
        }
    }
}

谢谢你的回答。这是一个工作实例。但你的解决办法和我的一样。正如我所说,我可以通过Composable.LoadAssembly调用加载插件。我的问题是为什么Composable.AddLocation dll只在那里加载了一次,我在调试输出中检查了这一点。但今天,同样的代码与Composable.AddLocation一起开始工作。我不知道原因,但看起来我的问题是假阳性,对不起。