public TypeGen(AssemblyGen myAssembly, TypeBuilder myType) { Assert.NotNull(myAssembly, myType); AssemblyGen = myAssembly; TypeBuilder = myType; }
private ILGen _initGen; // The IL generator for the .cctor() #endregion Fields #region Constructors public TypeGen(AssemblyGen myAssembly, TypeBuilder myType) { Assert.NotNull(myAssembly, myType); _myAssembly = myAssembly; _myType = myType; }
public DynInitHelper(AssemblyGen ag, string typeName) { _assemblyGen = ag; _typeName = typeName; //_typeBuilder = ag.DefinePublicType(typeName, typeof(object), true); //_typeGen = new TypeGen(ag, _typeBuilder); }
public GenContext(string assyName, string extension, string directory, bool createDynInitHelper) { AssemblyName aname = new AssemblyName(assyName); _assyGen = new AssemblyGen(aname, directory, extension, true); if ( createDynInitHelper ) _dynInitHelper = new DynInitHelper(_assyGen, "__InternalDynamicExpressionInits"); }
// Return the assembly locations that need to be verified private string[] SaveAssemblies() { if (!SaveSnippets) { return(new string[0]); } List <string> assemlyLocations = new List <string>(); // first save all assemblies to disk: if (_assembly != null) { string assemblyLocation = _assembly.SaveAssembly(); if (assemblyLocation != null) { assemlyLocations.Add(assemblyLocation); } _assembly = null; } if (_debugAssembly != null) { string debugAssemblyLocation = _debugAssembly.SaveAssembly(); if (debugAssemblyLocation != null) { assemlyLocations.Add(debugAssemblyLocation); } _debugAssembly = null; } return(assemlyLocations.ToArray()); }
public TypeGen DefineType(string name, Type parent, bool preserveName, bool emitDebugSymbols) { AssemblyGen ag = GetAssembly(emitDebugSymbols); TypeBuilder tb = ag.DefinePublicType(name, parent, preserveName); return(new TypeGen(ag, tb)); }
private AssemblyGen GetOrCreateAssembly(bool emitSymbols, ref AssemblyGen assembly) { if (assembly == null) { string suffix = (emitSymbols) ? ".debug" : ""; suffix += ".scripting"; Interlocked.CompareExchange(ref assembly, CreateNewAssembly(suffix, emitSymbols), null); } return assembly; }
public static AssemblyGen CreateModuleAssembly(string suid) { AssemblyGenAttributes genAttrs = ScriptDomainManager.Options.AssemblyGenAttributes; if (ScriptDomainManager.Options.DebugMode) { genAttrs |= AssemblyGenAttributes.EmitDebugInfo; } if (ScriptDomainManager.Options.DebugCodeGeneration) { genAttrs |= AssemblyGenAttributes.DisableOptimizations; } string outDir, fileName; GetCompiledSourceUnitAssemblyLocation(suid, out outDir, out fileName); AssemblyGen ag; string ext = ".dll"; //if (scriptCode.CodeBlock.Name == "ironscheme.boot.new") //{ // fileName = "ironscheme.boot.new"; // ext = ".dll"; //} // Try to create a file called "filename.<cnt>.exe", ensuring that the filename does not clash with an existing file int cnt = 0; for (; ;) { try { ag = new AssemblyGen(fileName, outDir, fileName + ext, genAttrs); if (ScriptDomainManager.Options.DebugMode) { ag.CreateSymWriter(); } break; } catch (FileNotFoundException) { throw; } catch (IOException) { // If a file already exits with the same name, try the next name in the sequence. ext = "_" + cnt.ToString() + ext; } } //ag.SetSourceUnit(su); return(ag); }
private TypeGen GenerateModuleGlobalsType(AssemblyGen ag) { TypeGen tg = ag.DefinePublicType(ModuleName == "ironscheme.boot.new" ? "#" : ModuleName, typeof(CustomSymbolDictionary)); tg.AddCodeContextField(); tg.DefaultConstructor = tg.TypeBuilder.DefineDefaultConstructor(MethodAttributes.Public); return(tg); }
private AssemblyGen GetOrCreateAssembly(bool emitSymbols, ref AssemblyGen assembly) { if (assembly == null) { string suffix = (emitSymbols) ? ".debug" : ""; suffix += ".scripting"; Interlocked.CompareExchange(ref assembly, CreateNewAssembly(suffix, emitSymbols), null); } return(assembly); }
public TypeBuilder DefineDelegateType(string name) { AssemblyGen assembly = GetAssembly(false); return(assembly.DefineType( name, typeof(MulticastDelegate), TypeAttributes.Class | TypeAttributes.Public | TypeAttributes.Sealed | TypeAttributes.AnsiClass | TypeAttributes.AutoClass, false )); }
public void Dump(string fileName) { if (_assembly != null && _assembly.SaveAndReloadAssemblies) { _assembly.Dump(fileName); _assembly = null; } if (_debugAssembly != null && _debugAssembly.SaveAndReloadAssemblies) { _debugAssembly.Dump(); _debugAssembly = null; } }
private GenContext(string directory, AssemblyName aname, string extension, bool createDynInitHelper, string sourceName) { // TODO: Make this settable from a *debug* flag #if DEBUG _isDebuggable = true; #else _isDebuggable = false; #endif _assyGen = new AssemblyGen(aname, directory, extension, _isDebuggable); if ( createDynInitHelper ) _dynInitHelper = new DynInitHelper(_assyGen, GenerateName()); if (_isDebuggable) _docWriter = ModuleBuilder.DefineDocument(sourceName, ClojureContext.Default.LanguageGuid, ClojureContext.Default.VendorGuid, Guid.Empty); _docInfo = Expression.SymbolDocument(sourceName); }
public static void SaveAndVerifyAssemblies() { if (!Shared.SaveSnippets) { return; } // Invoke the core AssemblyGen.SaveAssembliesToDisk via reflection to get the locations of assemlies // to be verified. Verify them using PEVerify.exe. // Do this before verifying outer ring assemblies because they will depend on // the core ones. // The order needs to be // 1) Save inner ring assemblies. // 2) Save outer ring assemblies. This has to happen before verifying inner ring assemblies because // inner ring assemblies have dependency on outer ring assemlies via generated IL. // 3) Verify inner ring assemblies. // 4) Verify outer ring assemblies. Assembly core = typeof(Expression).Assembly; Type assemblyGen = core.GetType(typeof(Expression).Namespace + ".Compiler.AssemblyGen"); //The type may not exist. string[] coreAssemblyLocations = null; if (assemblyGen != null) { MethodInfo saveAssemblies = assemblyGen.GetMethod("SaveAssembliesToDisk", BindingFlags.NonPublic | BindingFlags.Static); //The method may not exist. if (saveAssemblies != null) { coreAssemblyLocations = (string[])saveAssemblies.Invoke(null, null); } } string[] outerAssemblyLocations = Shared.SaveAssemblies(); if (coreAssemblyLocations != null) { foreach (var file in coreAssemblyLocations) { AssemblyGen.PeVerifyAssemblyFile(file); } } //verify outer ring assemblies foreach (var file in outerAssemblyLocations) { AssemblyGen.PeVerifyAssemblyFile(file); } }
private TypeGen GenerateModuleGlobalsType(AssemblyGen ag, ScriptCode sc) { var n = sc.CodeBlock.Name; switch (n) { case "visit-code": case "invoke-code": case "guard-code": TypeGen tg = ag.DefinePublicType("syntax-" + sc.CodeBlock.Name, typeof(CustomSymbolDictionary)); tg.AddCodeContextField(); tg.DefaultConstructor = tg.TypeBuilder.DefineDefaultConstructor(MethodAttributes.Public); return(tg); default: return(GenerateModuleGlobalsType(ag)); } }
public DynamicILGen CreateDynamicMethod(string methodName, Type returnType, Type[] parameterTypes, bool isDebuggable) { ContractUtils.RequiresNotEmpty(methodName, nameof(methodName)); ContractUtils.RequiresNotNull(returnType, nameof(returnType)); ContractUtils.RequiresNotNullItems(parameterTypes, nameof(parameterTypes)); #if FEATURE_REFEMIT if (Snippets.Shared.SaveSnippets) { AssemblyGen assembly = GetAssembly(isDebuggable); TypeBuilder tb = assembly.DefinePublicType(methodName, typeof(object), false); MethodBuilder mb = tb.DefineMethod(methodName, CompilerHelpers.PublicStatic, returnType, parameterTypes); return(new DynamicILGenType(tb, mb, mb.GetILGenerator())); } #endif DynamicMethod dm = ReflectionUtils.RawCreateDynamicMethod(methodName, returnType, parameterTypes); return(new DynamicILGenMethod(dm, dm.GetILGenerator())); }
private GenContext(string assyName, string extension, string directory, bool createDynInitHelper) { // TODO: Make this settable from a *debug* flag #if DEBUG _isDebuggable = true; #else _isDebuggable = false; #endif if (directory != null) { if (directory.Length > 0 && directory != ".") assyName = assyName.Replace("/", "."); } AssemblyName aname = new AssemblyName(assyName); _assyGen = new AssemblyGen(aname, directory, extension, _isDebuggable); if ( createDynInitHelper ) _dynInitHelper = new DynInitHelper(_assyGen, "__InternalDynamicExpressionInits"); }
public Snippets() { _assembly = null; // lazy init _debugAssembly = null; // lazy init }
public TypeGen(AssemblyGen myAssembly, TypeBuilder myType) { this._myAssembly = myAssembly; this._myType = myType; }
/// <summary> /// This takes an assembly name including extension and saves the provided ScriptCode objects into the assembly. /// /// The provided script codes can constitute code from multiple languages. The assemblyName can be either a fully qualified /// or a relative path. The DLR will simply save the assembly to the desired location. The assembly is created by the DLR and /// if a file already exists than an exception is raised. /// /// The DLR determines the internal format of the ScriptCode and the DLR can feel free to rev this as appropriate. /// </summary> public static void SaveToAssembly(string assemblyName, params SavableScriptCode[] codes) { ContractUtils.RequiresNotNull(assemblyName, "assemblyName"); ContractUtils.RequiresNotNullItems(codes, "codes"); // break the assemblyName into it's dir/name/extension string dir = Path.GetDirectoryName(assemblyName); if (String.IsNullOrEmpty(dir)) { dir = Environment.CurrentDirectory; } string name = Path.GetFileNameWithoutExtension(assemblyName); string ext = Path.GetExtension(assemblyName); // build the assembly & type gen that all the script codes will live in... AssemblyGen ag = new AssemblyGen(new AssemblyName(name), dir, ext, /*emitSymbols*/false); TypeBuilder tb = ag.DefinePublicType("DLRCachedCode", typeof(object), true); TypeGen tg = new TypeGen(ag, tb); var symbolDict = new Dictionary<SymbolId, FieldBuilder>(); // then compile all of the code Dictionary<Type, List<CodeInfo>> langCtxBuilders = new Dictionary<Type, List<CodeInfo>>(); foreach (SavableScriptCode sc in codes) { List<CodeInfo> builders; if (!langCtxBuilders.TryGetValue(sc.LanguageContext.GetType(), out builders)) { langCtxBuilders[sc.LanguageContext.GetType()] = builders = new List<CodeInfo>(); } KeyValuePair<MethodBuilder, Type> compInfo = sc.CompileForSave(tg, symbolDict); builders.Add(new CodeInfo(compInfo.Key, sc, compInfo.Value)); } MethodBuilder mb = tb.DefineMethod( "GetScriptCodeInfo", MethodAttributes.SpecialName | MethodAttributes.Public | MethodAttributes.Static, typeof(MutableTuple<Type[], Delegate[][], string[][], string[][]>), Type.EmptyTypes); ILGen ilgen = new ILGen(mb.GetILGenerator()); var langsWithBuilders = langCtxBuilders.ToArray(); // lang ctx array ilgen.EmitArray(typeof(Type), langsWithBuilders.Length, (index) => { ilgen.Emit(OpCodes.Ldtoken, langsWithBuilders[index].Key); ilgen.EmitCall(typeof(Type).GetMethod("GetTypeFromHandle", new[] { typeof(RuntimeTypeHandle) })); }); // builders array of array ilgen.EmitArray(typeof(Delegate[]), langsWithBuilders.Length, (index) => { List<CodeInfo> builders = langsWithBuilders[index].Value; ilgen.EmitArray(typeof(Delegate), builders.Count, (innerIndex) => { ilgen.EmitNull(); ilgen.Emit(OpCodes.Ldftn, builders[innerIndex].Builder); ilgen.EmitNew( builders[innerIndex].DelegateType, new[] { typeof(object), typeof(IntPtr) } ); }); }); // paths array of array ilgen.EmitArray(typeof(string[]), langsWithBuilders.Length, (index) => { List<CodeInfo> builders = langsWithBuilders[index].Value; ilgen.EmitArray(typeof(string), builders.Count, (innerIndex) => { ilgen.EmitString(builders[innerIndex].Code.SourceUnit.Path); }); }); // 4th element in tuple - custom per-language data ilgen.EmitArray(typeof(string[]), langsWithBuilders.Length, (index) => { List<CodeInfo> builders = langsWithBuilders[index].Value; ilgen.EmitArray(typeof(string), builders.Count, (innerIndex) => { ICustomScriptCodeData data = builders[innerIndex].Code as ICustomScriptCodeData; if (data != null) { ilgen.EmitString(data.GetCustomScriptCodeData()); } else { ilgen.Emit(OpCodes.Ldnull); } }); }); ilgen.EmitNew( typeof(MutableTuple<Type[], Delegate[][], string[][], string[][]>), new[] { typeof(Type[]), typeof(Delegate[][]), typeof(string[][]), typeof(string[][]) } ); ilgen.Emit(OpCodes.Ret); mb.SetCustomAttribute(new CustomAttributeBuilder( typeof(DlrCachedCodeAttribute).GetConstructor(Type.EmptyTypes), ArrayUtils.EmptyObjects )); tg.FinishType(); ag.SaveAssembly(); }
private TypeGen GenerateModuleGlobalsType(AssemblyGen ag, ScriptCode sc) { var n = sc.CodeBlock.Name; switch (n) { case "visit-code": case "invoke-code": case "guard-code": TypeGen tg = ag.DefinePublicType("syntax-" + sc.CodeBlock.Name, typeof(CustomSymbolDictionary)); tg.AddCodeContextField(); tg.DefaultConstructor = tg.TypeBuilder.DefineDefaultConstructor(MethodAttributes.Public); return tg; default: return GenerateModuleGlobalsType(ag); } }
private KeyValuePair<Type, Dictionary<string, string[]>> SaveType(AssemblyGen ag, string name) { _tg = ag.DefinePublicType(TypePrefix + name, _baseType, true); Dictionary<string, string[]> specialNames = ImplementType(); Type ret = FinishType(); return new KeyValuePair<Type, Dictionary<string, string[]>>(ret, specialNames); }
public static void SaveNewTypes(string assemblyName, IList<PythonTuple> types) { Assert.NotNull(assemblyName, types); AssemblyGen ag = new AssemblyGen(new AssemblyName(assemblyName), ".", ".dll", false); TypeBuilder tb = ag.DefinePublicType(_constructorTypeName, typeof(object), true); tb.SetCustomAttribute(typeof(PythonCachedTypeInfoAttribute).GetConstructor(Type.EmptyTypes), new byte[0]); MethodBuilder mb = tb.DefineMethod(_constructorMethodName, MethodAttributes.Public | MethodAttributes.Static, typeof(CachedNewTypeInfo[]), Type.EmptyTypes); ILGenerator ilg = mb.GetILGenerator(); // new CachedTypeInfo[types.Count] // we leave this on the stack (duping it) and storing into it. EmitInt(ilg, types.Count); ilg.Emit(OpCodes.Newarr, typeof(CachedNewTypeInfo)); int curType = 0; foreach (var v in types) { NewTypeInfo nti = NewTypeInfo.GetTypeInfo(String.Empty, v); var typeInfos = new NewTypeMaker(nti).SaveType(ag, "Python" + _typeCount++ + "$" + nti.BaseType.Name); // prepare for storing the element into our final array ilg.Emit(OpCodes.Dup); EmitInt(ilg, curType++); // new CachedNewTypeInfo(type, specialNames, interfaceTypes): // load the type ilg.Emit(OpCodes.Ldtoken, typeInfos.Key); ilg.Emit(OpCodes.Call, typeof(Type).GetMethod("GetTypeFromHandle")); // create the dictionary<str, str[]> of special names ilg.Emit(OpCodes.Newobj, typeof(Dictionary<string, string[]>).GetConstructor(new Type[0])); foreach (var specialName in typeInfos.Value) { // dup dict ilg.Emit(OpCodes.Dup); // emit key ilg.Emit(OpCodes.Ldstr, specialName.Key); // emit value int iVal = specialName.Value.Length; EmitInt(ilg, iVal); ilg.Emit(OpCodes.Newarr, typeof(string)); for (int i = 0; i < specialName.Value.Length; i++) { ilg.Emit(OpCodes.Dup); EmitInt(ilg, i); ilg.Emit(OpCodes.Ldstr, specialName.Value[0]); ilg.Emit(OpCodes.Stelem_Ref); } // assign to dict ilg.Emit(OpCodes.Call, typeof(Dictionary<string, string[]>).GetMethod("set_Item")); } // emit the interface types (if any) if (nti.InterfaceTypes.Count != 0) { EmitInt(ilg, nti.InterfaceTypes.Count); ilg.Emit(OpCodes.Newarr, typeof(Type)); for (int i = 0; i < nti.InterfaceTypes.Count; i++) { ilg.Emit(OpCodes.Dup); EmitInt(ilg, i); ilg.Emit(OpCodes.Ldtoken, nti.InterfaceTypes[i]); ilg.Emit(OpCodes.Call, typeof(Type).GetMethod("GetTypeFromHandle")); ilg.Emit(OpCodes.Stelem_Ref); } } else { ilg.Emit(OpCodes.Ldnull); } // crated the CachedNewTypeInfo and store it in the array ilg.Emit(OpCodes.Newobj, typeof(CachedNewTypeInfo).GetConstructors()[0]); ilg.Emit(OpCodes.Stelem_Ref); } ilg.Emit(OpCodes.Ret); tb.CreateType(); ag.SaveAssembly(); }
public static RecordTypeDescriptor GenerateRecordTypeDescriptor(AssemblyGen ag, object name, object parent, object uid, object issealed, object isopaque, object fields, object fieldtypes) { string n = SymbolTable.IdToString(RequiresNotNull<SymbolId>(name)); string id = uid is SymbolId ? SymbolTable.IdToString(RequiresNotNull<SymbolId>(uid)): uid as string; if (id != null) { RecordTypeDescriptor ngrtd; if (nongenerative.TryGetValue(n + id, out ngrtd)) { return ngrtd; } var type = ClrGenerator.GetTypeFast("record." + id + "." + n.Replace("&", "$")); if (type != null) { return RecordTypeDescriptor.Create(type, n, id, parent as RecordTypeDescriptor); } } bool @sealed = RequiresNotNull<bool>(issealed); bool opaque = RequiresNotNull<bool>(isopaque); RecordTypeDescriptor prtd = parent as RecordTypeDescriptor; // can be #f Type parenttype = typeof(object); if (prtd != null) { parenttype = prtd.type; } else if (n == "&condition") { parenttype = typeof(Condition); } TypeAttributes attrs = TypeAttributes.Public | TypeAttributes.Serializable; var rtd = new RecordTypeDescriptor { Name = n, @sealed = @sealed, opaque = opaque, ag = ag, Parent = prtd, uid = uid, generative = id == null || uid is string, }; if (@sealed) { attrs |= TypeAttributes.Sealed; } object gid = (object)id ?? Guid.NewGuid(); var ns = "record." + gid; var typename = ns + "." + n.Replace("&", "$"); TypeGen tg = ag.DefinePublicType(typename, parenttype, attrs); rtd.tg = tg; rtd.type = tg.TypeBuilder; if (id != null) { nongenerative[n + id] = rtd; } if (parenttype.IsSubclassOf(typeof(Condition))) { SetSymbolValueFast(SymbolTable.StringToObject(n + "-rtd"), rtd); } GeneratePredicate(n, rtd, tg); GenerateFields(fields, n, rtd, tg, fieldtypes); GenerateConstructor(rtd, tg, parenttype); return rtd; }
private TypeGen GenerateModuleGlobalsType(AssemblyGen ag) { TypeGen tg = ag.DefinePublicType(ModuleName == "ironscheme.boot.new" ? "#" : ModuleName, typeof(CustomSymbolDictionary)); tg.AddCodeContextField(); tg.DefaultConstructor = tg.TypeBuilder.DefineDefaultConstructor(MethodAttributes.Public); return tg; }
protected override SlotFactory CreateSlotFactory(ScriptCode scriptCode) { AssemblyGen ag = null; if (scriptCode.SourceUnit.Kind == SourceCodeKind.Default && scriptCode.CodeBlock.Name != "ironscheme.boot.new") { if (ScriptDomainManager.Options.DebugMode) { if ((ScriptDomainManager.Options.AssemblyGenAttributes & AssemblyGenAttributes.SaveAndReloadAssemblies) != 0) { ag = ScriptDomainManager.CurrentManager.Snippets.CurrentAssembly; //CreateModuleAssembly(scriptCode); } else { ag = ScriptDomainManager.CurrentManager.Snippets.DebugAssembly; } } else { if ((ScriptDomainManager.Options.AssemblyGenAttributes & AssemblyGenAttributes.SaveAndReloadAssemblies) != 0) { ag = ScriptDomainManager.CurrentManager.Snippets.CurrentAssembly; //CreateModuleAssembly(scriptCode); } else { ag = ScriptDomainManager.CurrentManager.Snippets.Assembly; } } } else { ag = ScriptDomainManager.CurrentManager.Snippets.CurrentAssembly; //CreateModuleAssembly(scriptCode); } ScriptDomainManager.CurrentManager.Snippets.CurrentAssembly = ag; TypeGen tg = GenerateModuleGlobalsType(ag, scriptCode); if (scriptCode.LibraryGlobals != null) { foreach (var kvp in scriptCode.LibraryGlobals) { var k = kvp.Key; var v = kvp.Value; var cg = v.Block.CreateGlobalMethodStub(tg); if (cg != null) { CodeGen._codeBlockStubs[v.Block] = cg; CodeGen._codeBlockLookup[k] = cg; } } } if (scriptCode.LibraryGlobalsX != null) { foreach (var kvp in scriptCode.LibraryGlobalsX) { var k = kvp.Key; var v = kvp.Value; var cg = v.Block.CreateGlobalMethodStub(tg); if (cg != null) { CodeGen._codeBlockStubsX[v.Block] = cg; CodeGen._codeBlockLookupX[k] = cg; } } } if (scriptCode.LibraryGlobalsN != null) { foreach (var kvp in scriptCode.LibraryGlobalsN) { var k = kvp.Key; var v = kvp.Value; var cgd = new List <CodeGenDescriptor>(); foreach (var i in v) { var cg = i.codeblock.Block.CreateGlobalMethodStub(tg); if (cg != null) { CodeGen._codeBlockStubsN[i.codeblock.Block] = cg; cgd.Add(new CodeGenDescriptor { arity = i.arity, varargs = i.varargs, cg = cg, }); } } CodeGen._codeBlockLookupN[k] = cgd.ToArray(); } } StaticFieldSlotFactory factory = new StaticFieldSlotFactory(tg); _languages[scriptCode.LanguageContext] = new LanguageInfo(factory, tg); return(factory); }
public static AssemblyGen CreateModuleAssembly(string suid) { AssemblyGenAttributes genAttrs = ScriptDomainManager.Options.AssemblyGenAttributes; if (ScriptDomainManager.Options.DebugMode) genAttrs |= AssemblyGenAttributes.EmitDebugInfo; if (ScriptDomainManager.Options.DebugCodeGeneration) genAttrs |= AssemblyGenAttributes.DisableOptimizations; string outDir, fileName; GetCompiledSourceUnitAssemblyLocation(suid, out outDir, out fileName); AssemblyGen ag; string ext = ".dll"; //if (scriptCode.CodeBlock.Name == "ironscheme.boot.new") //{ // fileName = "ironscheme.boot.new"; // ext = ".dll"; //} // Try to create a file called "filename.<cnt>.exe", ensuring that the filename does not clash with an existing file int cnt = 0; for (; ; ) { try { ag = new AssemblyGen(fileName, outDir, fileName + ext, genAttrs); if (ScriptDomainManager.Options.DebugMode) { ag.CreateSymWriter(); } break; } catch (FileNotFoundException) { throw; } catch (IOException) { // If a file already exits with the same name, try the next name in the sequence. ext = "_" + cnt.ToString() + ext; } } //ag.SetSourceUnit(su); return ag; }
// Return the assembly locations that need to be verified private string[] SaveAssemblies() { if (!SaveSnippets) { return new string[0]; } List<string> assemlyLocations = new List<string>(); // first save all assemblies to disk: if (_assembly != null) { string assemblyLocation = _assembly.SaveAssembly(); if (assemblyLocation != null) { assemlyLocations.Add(assemblyLocation); } _assembly = null; } if (_debugAssembly != null) { string debugAssemblyLocation = _debugAssembly.SaveAssembly(); if (debugAssemblyLocation != null) { assemlyLocations.Add(debugAssemblyLocation); } _debugAssembly = null; } return assemlyLocations.ToArray(); }