[Mono-bugs] [Bug 66180][Cri] New - Activator.CreateInstance on RunAndSave Dynamic assembly throws NotSupportedException
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Fri, 17 Sep 2004 12:27:56 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by martin.tapp@cae.com.
http://bugzilla.ximian.com/show_bug.cgi?id=66180
--- shadow/66180 2004-09-17 12:27:56.000000000 -0400
+++ shadow/66180.tmp.1839 2004-09-17 12:27:56.000000000 -0400
@@ -0,0 +1,71 @@
+Bug#: 66180
+Product: Mono: Class Libraries
+Version: unspecified
+OS: Red Hat 9.0
+OS Details:
+Status: NEW
+Resolution:
+Severity: 040 One week
+Priority: Critical
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: martin.tapp@cae.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Activator.CreateInstance on RunAndSave Dynamic assembly throws NotSupportedException
+
+Description of Problem:
+
+Using Activator.CreateInstance on a type that was created in a dynamic
+assembly with RunAndSave throws NotSupportedException.
+
+
+Steps to reproduce the problem:
+
+AssemblyName wAsmName = new AssemblyName();
+wAsmName.Name = "MyAssembly";
+
+AssemblyBuilder wAsmBuilder =
+AppDomain.CurrentDomain.DefineDynamicAssembly(wAsmName,AssemblyBuilderAccess.RunAndSave,"/some/path");
+
+string wAssemblyDll = "/some/path/MyAssembly.dll";
+
+ModuleBuilder wModuleBuilder =
+wAsmBuilder.DefineDynamicModule(wAssemblyDll,wAssemblyDll,false);
+
+TypeBuilder wTypeBuilder =
+wModuleBuilder.DefineType("MyType",(TypeAttributes)TypeAttributes.Public|TypeAttributes.Class);
+
+wTypeBuilder.DefineDefaultConstructor(MethodAttributes.Public);
+wTypeBuilder.CreateType();
+
+wAsmBuilder.Save(wAssemblyDll);
+
+Type[] wTypes = wAsmBuilder.GetTypes();
+int i;
+for(i=0; i<wTypes.Length; i++)
+{
+ Type wType = wTypes[i];
+ try
+ {
+ Object wObject = Activator.CreateInstance(wType);
+ }
+ catch(Exception e)
+ {
+ // Fail
+ }
+}
+
+
+Actual Results:
+Throws NotSupportedException.
+
+
+Expected Results:
+Creates an instance of MyType (works fine under MS.NET)
+
+
+How often does this happen?
+Always