[Mono-dev] System.Collections.Generic.Dictionary.CopyTo inaccessible due to protection level

Antti S. Lankila alankila at bel.fi
Sun Nov 25 08:09:40 EST 2007

Valentin Sawadski wrote:
> It explicitly implements copy to in line 643 and 653. So CopyTo is
> publicly available. If you refer to the CopyTo at line 275, this is
> being called by the explicit implementation of it.

*Sigh*. Let this test program demonstrate:

alankila at zeus:~/mono-hacks% gmcs bug.cs -o bug.exe
warning CS8029: Compatibility: Use -out:FILE instead of --output FILE or 
bug.cs(9,11): error CS0122: 
int)' is inaccessible due to its protection level
/usr/lib/mono/2.0/mscorlib.dll (Location of the symbol related to 
previous error)
Compilation failed: 1 error(s), 1 warnings
zsh: exit 1     gmcs bug.cs -o bug.exe
alankila at zeus:~/mono-hacks% cat bug.cs
using System;
using System.Collections.Generic;

class proggie {
    public static void Main(string[] args) {
        Dictionary<string,object> x = new Dictionary<string, object>();
        x["this"] = 0;
        KeyValuePair<string,object>[] y = new 
        x.CopyTo(y, 0);
        Console.WriteLine("woohoo, copied {0} => {1}!", y[0].Key, 

But on my SVN version of mono, I have added the public modifier and the 
code becomes suddenly runnable.


More information about the Mono-devel-list mailing list