I need a ReadOnlyDictionary
. All posts told me that there is none in .Net 4.0. For that reason I created my own implementation.
After doing that Resharper 5.1 told me about an ambiguous reference to System.Collections.ObjectsModel.ReadOnlyDictionary
but the code is compiling without errors.
I tried to use this implementation but it's not accessible. Why?
I wrote the following Code to test whether there is a ReadOnlyDictionary
in .Net 4.0:
var foo = from assembly in AppDomain.CurrentDomain.GetAssemblies()
where assembly.FullName.Contains("mscorlib")
from type in assembly.GetTypes()
where type.Name.StartsWith("ReadOnly")
select type.FullName + " " + assembly.FullName;
And the surprising result is:
System.Collections.ReadOnlyCollectionBase mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Collections.ObjectModel.ReadOnlyCollection`1 mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Collections.ObjectModel.ReadOnlyDictionary`2 mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Collections.ObjectModel.ReadOnlyDictionaryHelpers mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Runtime.InteropServices.WindowsRuntime.ReadOnlyArrayAttribute mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Runtime.InteropServices.WindowsRuntime.ReadOnlyDictionaryKeyCollection`2 mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Runtime.InteropServices.WindowsRuntime.ReadOnlyDictionaryKeyEnumerator`2 mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Runtime.InteropServices.WindowsRuntime.ReadOnlyDictionaryValueCollection`2 mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Runtime.InteropServices.WindowsRuntime.ReadOnlyDictionaryValueEnumerator`2 mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Security.ReadOnlyPermissionSet mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Security.ReadOnlyPermissionSetEnumerator mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Collections.ArrayList+ReadOnlyList mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
System.Collections.ArrayList+ReadOnlyArrayList mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
There is a ReadOnlyDictionary
in .Net 4.0. I used dotPeek 1.1 to reflect for this type and it’s public.
Why is this type inaccessible? What can I do to prevent the ambiguous reference in Resharper 5.1 (7.1 doesn’t have this problem)?