private Assembly GetAssembly(byte[] data) { if (data == null) { throw new BadImageFormatException("Assembly data can not be null"); } Assembly asm = Assembly.Load(data); DotNetScriptEngine.RegisterInMemoryAssembly(asm.GetName(), data); return(asm); }
private static void LoadEngines() { ArrayList dllNames = new ArrayList(); IZeusScriptingEngine engine = new DotNetScriptEngine(); //TODO:FIX THIS!!! string prefix = @"E:\pub\Source Code\MyGeneration\SourceControl\zeus\source\ZeusSolution\ZeusExtremeTest\bin\debug\"; _engines = new Hashtable(); _engines.Add(engine.EngineName, engine); // Load text File with DLL file names if (File.Exists(prefix + ENGINE_CONFIG_FILE)) { StreamReader reader = new StreamReader(prefix + ENGINE_CONFIG_FILE, Encoding.UTF8); string line = reader.ReadLine(); while (line != null) { dllNames.Add(line); line = reader.ReadLine(); } reader.Close(); Assembly assembly; foreach (string dllPath in dllNames) { assembly = DynamicAssemblyTools.LoadDynamicAssembly(prefix + dllPath); if (assembly != null) { object[] tmp = DynamicAssemblyTools.InstantiateClassesByType(assembly, typeof(IZeusScriptingEngine)); for (int i = 0; i < tmp.Length; i++) { engine = tmp[i] as IZeusScriptingEngine; if (engine != null) { _engines.Add(engine.EngineName, engine); } } } } } }