[Mono-bugs] [Bug 61048][Nor] New - Unable to get Type array from Module using FindTypes...
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Fri, 2 Jul 2004 01:17:29 -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 banil@novell.com.
http://bugzilla.ximian.com/show_bug.cgi?id=61048
--- shadow/61048 2004-07-02 01:17:29.000000000 -0400
+++ shadow/61048.tmp.7399 2004-07-02 01:17:29.000000000 -0400
@@ -0,0 +1,108 @@
+Bug#: 61048
+Product: Mono: Runtime
+Version: unspecified
+OS: Red Hat 9.0
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: banil@novell.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Summary: Unable to get Type array from Module using FindTypes...
+
+Description of Problem:
+Unable to get Type array from Module using FindTypes...
+Not sure if its a bug in Runtime or somewhere else, but compilation seems
+to succeed...
+
+
+Steps to reproduce the problem:
+Sample code with line numbers...
+
+01: using System;
+02: using System.Reflection;
+
+ 03:
+04: namespace ReflectionModule_Examples
+05: {
+06: class MyMainClass
+07: {
+08: static void Main()
+09: {
+10: Console.WriteLine("Test01::Main Begin");
+11: Module[] moduleArray;
+
+ 12:
+13: moduleArray =
+Assembly.GetExecutingAssembly().GetModules(false);
+
+ 14:
+15: // In a simple project with only one module, the module at
+index
+16: // 0 will be the module containing these classes.
+17: Module myModule = moduleArray[0];
+
+ 18:
+19: Type[] tArray = null;
+
+ 20:
+21: Console.WriteLine("Test01::Main Before calling FindTypes");
+22: tArray = myModule.FindTypes(Module.FilterTypeName, "My*");
+23: Console.WriteLine("Test01::Main after calling FindTypes");
+
+ 24:
+25: foreach(Type t in tArray)
+26: {
+27: Console.WriteLine("Found a module beginning with My*:
+{0}.", t.Name);
+28: }
+29: }
+30: }
+
+ 31:
+32: class MySecondClass
+33: {
+34: }
+
+ 35:
+36: // This class does not fit the filter criteria My*.
+37: class YourClass
+38: {
+39: }
+40: }
+
+
+Actual Results:
+Compilation goes on fine and does not indicate any issues...
+On execution the output is as follows:
+---------------------------------------------
+Test01::Main Begin
+Test01::Main Before calling FindTypes
+
+Unhandled Exception: System.NullReferenceException: Object reference not
+set to an instance of an object
+in <0x00085> System.Reflection.Module:FindTypes
+(System.Reflection.TypeFilter,object)
+in <0x00094> ReflectionModule_Examples.MyMainClass:Main ()
+----------------------------------------------
+Line 22 seems to have some problem...
+
+Expected Results:
+Test01::Main Begin
+Test01::Main Before calling FindTypes
+Test01::Main after calling FindTypes
+Found a module beginning with My*: MyMainClass.
+Found a module beginning with My*: MySecondClass.
+
+How often does this happen?
+Always
+
+Additional Information:
+This runs fine on .NET.
+In fact this is a sample taken from MSDN...
+http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemreflectionmoduleclassfindtypestopic.asp