[Mono-bugs] [Bug 45197][Nor] New - Using static event causes CS0176

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
Fri, 20 Jun 2003 11:07:38 -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 joergr@voelcker.com.

http://bugzilla.ximian.com/show_bug.cgi?id=45197

--- shadow/45197	Fri Jun 20 11:07:38 2003
+++ shadow/45197.tmp.22299	Fri Jun 20 11:07:38 2003
@@ -0,0 +1,68 @@
+Bug#: 45197
+Product: Mono/MCS
+Version: unspecified
+OS: Debian Woody
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: Misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: JoergR@voelcker.com               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Using static event  causes CS0176
+
+Please fill in this template when reporting a bug, unless you know what you
+are doing.
+Description of Problem:
+If you define a static event in a class and call it from a member function
+it results in compiler error 'CS0176:Static member `...' cannot be accessed
+with an instance reference, qualify with a type name instead'.
+
+
+Steps to reproduce the problem:
+using System;
+
+namespace Test
+{
+	public class Dummy
+	{
+		public static event EventHandler Test;
+			
+		public Dummy()
+		{
+		}
+
+		public void Fire()
+		{
+			if ( Test != null )
+				Test(this, EventArgs.Empty);
+		}
+	}
+	
+	public sealed class TestClass
+	{
+		public static void Main()
+		{
+			Dummy d = new Dummy();
+			
+			d.Fire();
+		}
+	}
+}
+
+Actual Results:
+StaticEvent.cs(15) error CS0176: Static member `Test' cannot be accessed
+with an instance reference, qualify with a type name instead
+
+Expected Results:
+This source should compile fine. CSC compiles it without problems.
+
+How often does this happen? 
+Always.
+
+Additional Information: