コード例 #1
0
        static Assembly LoadPlugin(string relativePath)
        {
            // Navigate up to the solution root
            string root           = GetRootDirectory();
            string pluginLocation = Path.GetFullPath(Path.Combine(root, relativePath.Replace('\\', Path.DirectorySeparatorChar)));

            Console.WriteLine($"Loading loaders from: {pluginLocation}");
            PluginLoadContext loadContext = new PluginLoadContext(pluginLocation);

            return(loadContext.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(pluginLocation))));
        }
コード例 #2
0
        static Assembly LoadPlugin(string relativePath)
        {
            // Navigate up to the solution root
            string root = Path.GetFullPath(Path.Combine(
                                               Path.GetDirectoryName(
                                                   Path.GetDirectoryName(
                                                       Path.GetDirectoryName(
                                                           Path.GetDirectoryName(
                                                               Path.GetDirectoryName(typeof(Program).Assembly.Location)))))));

            string pluginLocation = Path.GetFullPath(Path.Combine(root, relativePath.Replace('\\', Path.DirectorySeparatorChar)));
            //Console.WriteLine($"Loading commands from: {pluginLocation}");
            PluginLoadContext loadContext = new PluginLoadContext(pluginLocation); //DLL von Plugin.

            return(loadContext.LoadFromAssemblyName(new AssemblyName(Path.GetFileNameWithoutExtension(pluginLocation))));
        }