[Mono-bugs] [Bug 75652][Nor] New - Assembly.GetType(string, bool,
bool) overload be busted, yo.
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Wed Jul 27 19:59:58 EDT 2005
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 l33ts0n at gmail.com.
http://bugzilla.ximian.com/show_bug.cgi?id=75652
--- shadow/75652 2005-07-27 19:59:58.000000000 -0400
+++ shadow/75652.tmp.30267 2005-07-27 19:59:58.000000000 -0400
@@ -0,0 +1,89 @@
+Bug#: 75652
+Product: Mono: Class Libraries
+Version: 1.1
+OS:
+OS Details: Ubuntu
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs at ximian.com
+ReportedBy: l33ts0n at gmail.com
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Assembly.GetType(string, bool, bool) overload be busted, yo.
+
+****Description of Problem:
+
+Assembly.GetType(string, bool, bool) overload fails to handle retrieving
+types from an assembly generated in memory. Works perfectly under
+Microsoft.NET runtime.
+
+Note that this overload only fails when accessing an assembly generated *IN
+MEMORY*; loading an assembly via Assembly.LoadFile() or any other method
+works perfectly fine.
+
+****Steps to reproduce the problem:
+
+Compile the following C# application and attempt to run it:
+[CODE]
+using System;
+using System.Text;
+using System.IO;
+using System.Reflection;
+using Microsoft.CSharp;
+using System.CodeDom.Compiler;
+class MainClass
+{
+ public static void Main(string[] args)
+ {
+ StringBuilder code = new StringBuilder();
+ StringWriter writer = new StringWriter(code);
+ writer.WriteLine("using System;");
+ writer.WriteLine("public sealed class MyClass : System.Object");
+ writer.WriteLine("{");
+ writer.WriteLine("public static string foo(string input)");
+ writer.WriteLine("{ return input; }");
+ writer.WriteLine("private MyClass() { }");
+ writer.WriteLine("}");
+
+ CSharpCodeProvider cp = new CSharpCodeProvider();
+ ICodeCompiler ic = cp.CreateCompiler();
+ CompilerParameters param = new CompilerParameters();
+ param.GenerateInMemory = true;
+ param.GenerateExecutable = false;
+ param.ReferencedAssemblies.Add("system");
+
+ CompilerResults results = ic.CompileAssemblyFromSource(param,
+code.ToString());
+
+ Type myClass = results.CompiledAssembly.GetType("MyClass", true, true);
+ MethodInfo foo = myClass.GetMethod("foo");
+ string output = (string)foo.Invoke(null, new object[] { "Jpop rocks!" });
+ Console.WriteLine(output);
+ }
+}
+[CODE]
+
+****Actual Results:
+
+A tersely worded "null reference exception." Poking a bit under the hood,
+Mono actually complains about a System.TypeLoadException. but don't quote
+me on that - I only noticed the exception rising when I wrote this
+test-case in Boo. In C#, just a very uninformative null reference exception.
+
+****Expected Results:
+
+Invokation of the static method 'foo', resulting in the string 'Jpop
+Rocks!' printed to STDOUT.
+
+****How often does this happen?
+
+When-ever you run the application!
+
+****Additional Information:
+
+Running under Mono 1.1.8.3 ('or something').
More information about the mono-bugs
mailing list