Bugzilla – Bug 315977
[PATCH] Calling GetTypes on a Dynamically generated assembly throws an OOM Exception
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by grompf@sublimeintervention.com 2004-09-08 21:14:23 MST ---- The following code runs on MS.NET v1.1 but throws and OutOfMemoryException on mono: using System; using System.Reflection; using System.Reflection.Emit; using System.Runtime.InteropServices; using System.Threading; namespace Apple.Foundation { public class Test { static Assembly generated = null; static Assembly GenerateAssembly() { AssemblyName an = new AssemblyName(); an.Name = "Test"; AssemblyBuilder builder = AppDomain.CurrentDomain.DefineDynamicAssembly(an, AssemblyBuilderAccess.Run); ModuleBuilder module = builder.DefineDynamicModule(an.Name); TypeBuilder typebuilder = module.DefineType("Generator", TypeAttributes.Public); typebuilder.CreateType(); module.CreateGlobalFunctions(); return module.Assembly; } static Assembly TypeResolve(object sender, ResolveEventArgs args) { Console.WriteLine ("Returning resolver..."); if (generated == null) generated = GenerateAssembly(); // Mono OOM here foreach (Type t in generated.GetTypes()) Console.WriteLine("TYPE={0}", t); return generated; } static void Main (string[] args) { AppDomain.CurrentDomain.TypeResolve += new ResolveEventHandler (TypeResolve); Type t = System.Type.GetType("Generator"); } } } ---- Additional Comments From grompf@sublimeintervention.com 2004-09-08 22:57:26 MST ---- Created an attachment (id=166746) proposed patch ---- Additional Comments From grompf@sublimeintervention.com 2004-09-08 22:57:56 MST ---- The attached patch causes mono to act the same as MS.NET for calling GetTypes on dynamically emitted assemblies. ---- Additional Comments From vargaz@freemail.hu 2004-09-09 09:00:56 MST ---- This is ok to check in, but please fix the formatting (space between if and (, etc). ---- Additional Comments From grompf@sublimeintervention.com 2004-09-09 12:06:01 MST ---- spacing fixed and applied to head Imported an attachment (id=166746) Unknown bug field "cf_op_sys_details" encountered while moving bug <cf_op_sys_details>OSX 10.3.4</cf_op_sys_details> Unknown operating system unknown. Setting to default OS "Other".