[Mono-bugs] [Bug 53454][Nor] New - Visual Studio 2003 ASP special events are never called.

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Wed, 28 Jan 2004 05:33:24 -0500 (EST)

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 mordechait@mainsoft.com.


--- shadow/53454	2004-01-28 05:33:23.000000000 -0500
+++ shadow/53454.tmp.10261	2004-01-28 05:33:23.000000000 -0500
@@ -0,0 +1,86 @@
+Bug#: 53454
+Product: Mono/Class Libraries
+Version: unspecified
+OS Details: 
+Status: NEW   
+Priority: Normal
+Component: Sys.Web
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: mordechait@mainsoft.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+Summary: Visual Studio 2003 ASP special events are never called.
+MS Visual Studio generates default implementations of some Application
+events in global.asax.cs or global.asax.vb
+When using vb, MS Visual Studio makes these functions public because this
+is the default in VB when no access flag is explicitly specified.
+The problem is that in
+System.Web.HttpApplicationFactory.ReflectOnApplicationType() of mono's
+implementation, only non public methods are used for events.
+Steps to reproduce the problem:
+1. Open in Visual Studio 2003 a new VB Web Application . 
+2. goto the Global.asax.vb code behind and implement the following method
+    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
+        System.Console.WriteLine("Application_Start")
+    End Sub
+3. run the application and watch the console.
+Actual Results:
+the string "Application_Start" never appears.
+Expected Results:
+see the "Application_Start" when the ASP page loads.
+How often does this happen? 
+Additional Information:
+the fix:
++++ HttpApplicationFactory.cs   Wed Jan 28 11:31:18 2004
+@@ -162,8 +162,7 @@
+                        if (baseType == typeof (HttpApplication))
+                                return appTypeEventHandlers;
+-                       flags = BindingFlags.NonPublic |
+BindingFlags.Static | BindingFlags.Instance;
++                       flags = BindingFlags.NonPublic |
+BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public;
+                        methods = appType.GetMethods (flags);
+                        foreach (MethodInfo m in methods) {
+                                if (IsEventHandler (m))
+First: this problem occurs only in VB not C#. why ? different semantics
+between the default flags for a method.
+In C# when you don't specify what the access flags for a method
+it accepts the default flag: "internal" (Family in .Net terminology).
+In VB the default is public.
+Now comes ASP and Global.asax.vb into the play. 
+All the events there have the default method flag. When an ASP page
+loads up it tries to search those methods by signature matching
+(see Microsoft method in System.Web.dll:
+Therefor when reflecting those events in
+System.Web.HttpApplicationFactory::ReflectOnApplicationType() set the
+BindingFlags to be NonPublic or Static or Instance or Public (value=60).
+The Mono code in this section is not 1-to-1 with microsoft and I believe
+has a minor glitch.
+The current Mono code neglected the Public flag which caused the VB
+methods in Global.asax to be ignored.
+The current flags are set to value 44 which is simply not enough.