Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
The System.ObjectModel.dll facade assembly for Xamarin.iOS does not export the ReadOnlyDictionary type, so using ReadOnlyDictionary from a PCL does not work. On the other hand, using ReadOnlyDictionary directly in a Xamarin.iOS project _does_ work.
## Steps to reproduce
1. Create a new Xamarin.iOS project, and a new PCL Profile7 (.NET 4.5 + Windows Store) PCL project.
2. Reference the ReadOnlyDictionary type in the PCL project. For example, add a subclass:
> public class MyDictionary<TKey, TValue> : ReadOnlyDictionary<TKey, TValue>
> public MyDictionary (IDictionary<TKey, TValue> dictionary) : base (dictionary)
3. Reference the subclass from the Xamarin.iOS project:
> new MyDictionary<string, string>(new Dictionary<string, string>());
4. Attempt to build the Xamarin.iOS project
> error CS1684: Reference to type `System.Collections.ObjectModel.ReadOnlyDictionary`2<TKey,TValue>' claims it is defined assembly `System.ObjectModel, Version=188.8.131.52, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a', but it could not be found
## Additional information
`monodis --exported` confirms that the type is not present in the Xamarin.iOS facade:
> $ monodis --exported /Developer/MonoTouch/usr/lib/mono/2.1/Facades/System.ObjectModel.dll | grep Dictionary
... but is present in the Xamarin.Android facade:
> $ monodis --exported /Library/Frameworks/Xamarin.Android.framework/Versions/4.10.1-68/lib/xbuild-frameworks/MonoAndroid/v1.0/Facades/System.ObjectModel.dll | grep Dictionary
> 1: System.Collections.ObjectModel.ReadOnlyDictionary`2 is in assemblyref 1, index=200077d, flags=0x200000
## Possible workaround
One workaround seems to be to copy the System.ObjectModel.dll facade assembly from Xamarin.Android:
> C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\Facades\System.ObjectModel.dll
... to the Xamarin.iOS folder:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoTouch\v1.0\Facades\System.ObjectModel.dll
And on the Mac build host, from:
## Version information
Problem and workaround tested on:
- Xamarin.iOS 7.0.4 and Mono 3.2.5
- Xamarin.iOS 184.108.40.206 and Mono 3.2.6
Interestingly, the MSDN don't list ReadOnlyDictionary as PCL compatible (http://msdn.microsoft.com/en-us/library/gg712875(v=vs.110).aspx) but it is a part of Microsoft's facades (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile7\System.ObjectModel.dll).
It is marked as conditional. The most likely reason for this is that it was not part of XI's API in October.
I have removed the conditional:
We need to bump XI to this revision.
This was the only difference in this Facade Assembly between XI and XA, so copying the one from XA is a good workaround.
Not fixed in X.iOS 7.0.6
System.TypeLoadException: Could not load type 'System.Collections.ObjectModel.ReadOnlyDictionary`2' from assembly 'System.ObjectModel, Version=220.127.116.11, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1[SDSClient_Core.Services.REMOTE_SERVICE_ERROR_CODES].Start[<UploadFileAsync>d__51] (SDSClient_Core.Services.Implementations.<UploadFileAsync>d__51& stateMachine) [0x0001b] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Runtime.CompilerServices/AsyncTaskMethodBuilder_T.cs:107
at SDSClient_Core.Services.Implementations.DefaultRemoteService.UploadFileAsync (Int32 dataRoomId, System.String fileName, System.String comment, System.String parentPathParts, DateTime expiration, System.IO.Stream sourceStream, IProgress`1 progress, CancellationToken ct) [0x00000] in <filename unknown>:0
at SDSClient_Core.RemoteDataAccess+<>c__DisplayClass76.<UploadFileAsync>b__74 ()
Just hit the same problem here in my project. I don't want to start copying DLLs around. Does that mean the only option for now is to NOT use ReadOnlyDictionary?
Will this issue be addressed/fixed?
This is still an issue in 18.104.22.168.
Can you guys please REOPEN the bug when a fix is not working for you? My default bug list does not include anything in the RESOLVED FIXED state, so it's easy to miss out that further action is required. Thanks.
I'd love to do that but I don't have permissions.
Closing as the issue was fixed some time ago