Bugzilla – Bug 319296
[GMCS] compilation error: incorrect generation of error CS0122:
Last modified: 2007-09-15 21:24:23 UTC
---- Reported by awaddell@fnfr.com 2005-10-14 13:47:07 MST ---- Please fill in this template when reporting a bug, unless you know what you are doing. Description of Problem: I get: error CS0122: `GenericsBugLib.MyClass<System.Int32>.ListChanged' is inaccessible due to its protection level on lines like list.ListChanged += new ListChangedEventHandler(list_ListChanged); even thought the event in question is publicly declared. This only seems to happen if the event is declared in a different assembly. Steps to reproduce the problem: 1. Compile the following as a dll using System; using System.Collections.Generic; using System.Text; using System.ComponentModel; namespace GenericsBugLib { public class MyClass<TItem> { public MyClass() { } public event ListChangedEventHandler ListChanged; public void AddListChangedEventHandler(ListChangedEventHandler handler) { ListChanged += handler; } protected void OnListChanged(ListChangedEventArgs e) {} } } "C:\Program Files\Mono-1.1.9.2\bin\gmcs" /noconfig /nowarn:1691,67 /warn:4 /define:DEBUG;TRACE /define:MONO;HEADLESS;FIXME /reference:System;System.Data;System.Xml /out:mono\Debug\GenericsBugLib.dll /target:library Class1.cs Properties\AssemblyInfo.cs 2. Compile the following as an exe: //#define WORKAROUND using System; using System.Collections.Generic; using System.Text; using System.ComponentModel; using GenericsBugLib; namespace GenericsBug { class Program { static void Main(string[] args) { MyClass<int> list = new MyClass<int>(); #if ! WORKAROUND list.ListChanged += new ListChangedEventHandler(list_ListChanged); #else list.AddListChangedEventHandler(new ListChangedEventHandler(list_ListChanged)); #endif } static void list_ListChanged(object sender, ListChangedEventArgs e) { } } } "C:\Program Files\Mono-1.1.9.2\bin\gmcs" /noconfig /nowarn:1691,67 /warn:4 /define:DEBUG;TRACE /define:MONO;HEADLESS;FIXME /reference:..\GenericsBugLib\mono\Debug\GenericsBugLib.dll /reference:System;System.Data;System.Xml /out:mono\Debug\GenericsBug.exe /target:exe Program.cs Properties\AssemblyInfo.cs 3. experiment with #define WORKAROUND Actual Results: w/o WORKAROUND Program.cs(19,18): error CS0122: `GenericsBugLib.MyClass<System.Int32>.ListChanged' is inaccessible due to its protection level Expected Results: clean compile How often does this happen? always Additional Information: compiles cleanly with MS compiler ---- Additional Comments From miguel@ximian.com 2006-01-04 12:17:33 MST ---- Am setting this priority to major. ---- Additional Comments From martin@ximian.com 2006-01-09 05:48:06 MST ---- Post-GUAM bug-fixing pass; week #2/2006. ---- Additional Comments From martin@ximian.com 2006-01-10 17:07:01 MST ---- Fixed in SVN; r55341 and r55342. ---- Additional Comments From martin@ximian.com 2006-01-10 17:08:44 MST ---- *** https://bugzilla.novell.com/show_bug.cgi?id=MONO77134 has been marked as a duplicate of this bug. ***