Explicitly manage .NET assemblies |
You want to exclude or add assemblies to the list of streamed assemblies.
To add assemblies, call the Add method on AdditionalDependencies. To exclude assemblies to send, call the Add method on ExcludedDependencies.
using System; using System.IO; using AGI.Parallel.Client; using AGI.Parallel.Infrastructure; namespace CodeSamples { class Program { static void Main(string[] args) { Task task = new NeedsAdditionalFiles(); using (IJobScheduler scheduler = new ClusterJobScheduler("localhost")) { scheduler.Connect(); Job job = scheduler.CreateJob(); // Add the assembly by specifying the fullpath of the assembly using AddDependency. job.AdditionalDependencies.Add("C:\\AnotherLibrary.dll"); job.AdditionalDependencies.Add("C:\\YetAnotherLibrary.dll"); // Exclude the assembly by specifing it's .NET FullName. job.ExcludedDependencies.AddFromAssemblyName("MyAssemblyThatIWantToExclude, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"); job.AddTask(task); job.Submit(); job.WaitUntilDone(); } } [Serializable] internal class NeedsAdditionalFiles : Task { public override void Execute() { // Often times, the use case for the tasks to do this is because of late binding. Type t = Type.GetType("AnotherLibrary.MyClass"); Object obj = Activator.CreateInstance(t); } } } }
Internally, the assemblies needed to run a task are automatically detected and the assemblies needed to run a .NET task are automatically streamed. At times, additional control over this automatic behavior may be needed. For instance, client applications may not have a dependency on some required assemblies if they are using dependency injection or reflection to get types, so it will be necessary to send the assemblies manually.
STK Parallel Computing Server 2.9 API for .NET