Bug 8035 - Shim Assembly issues for PCL
Summary: Shim Assembly issues for PCL
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools (show other bugs)
Version: 6.0.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Martin Baulig
Depends on:
Reported: 2012-10-28 12:31 UTC by Stuart Lodge
Modified: 2013-08-14 09:30 UTC (History)
6 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description Stuart Lodge 2012-10-28 12:31:48 UTC
Hi Xamarin

PCL support is really getting close to being good now - and I've gotten a long long way with building lots of code cross-platform.

However, there are a couple more small problems/issues I'd like to try to discuss with your team - but I'm not sure how to do it?

The problems are basically all to do with the special Microsoft namespaced Assemblies - especially System.Windows and System.Net.

I've worked around these Assemblies using Shim DLLs which use type forwarding to the MonoTouch locations of the classes (e.g.see https://github.com/slodge/MvvmCross/tree/vnext/Cirrious/System.Windows)

However, there are 2 problems with these DLLs:

1. When building in MonoDevelop then the System.Net Assembly tries to give friend access to the full Mono System.Net DLL - see http://forums.xamarin.com/discussion/195/building-a-system-net-surrogate-dll-under-monotouch-avoiding-a-friend-access-clash#latest

2. When building on Windows (using VSMonoTouch) then there are some 'strong naming' problems which can occur if you reference a Type in both PCL and native code. For and example of this, see https://github.com/slodge/MvvmCross/issues/41

I'm sure there must be an easy workaround for 1 using some patch on the MSBuild files - but I haven't worked it out yet.

For 2, I've discussed the problem with @dsplaisted on the BCL/PCL teams at Microsoft - he suggested that there are some possible workarounds to do with code signing - see http://stackoverflow.com/questions/13028321/portable-class-library-strong-assembly-reference-problems-in-monotouch-monodroid

He also suggested that Microsoft could perhaps provide signed Shim Assemblies - which I think would help

Sorry this is a bit long as a bug report. If you need more specific information please ask.

Comment 1 Rolf Bjarne Kvinge [MSFT] 2012-10-29 08:40:18 UTC
I believe we should provide a System.Net.dl shim assembly - we moved the types thus we must ensure callers of the old assembly can still access those types.

In the meantime time you can probably sign your System.Net.dll as we do it ourselves, using ecma.pub and mono.snk from here: https://github.com/mono/mono/tree/master/mcs/class
Comment 2 Stuart Lodge 2012-10-30 03:51:29 UTC
Thanks Rolf

Please excuse my ignorance on this one. I've read up a little on this, but I've never actually signed a DLL in my life!

I think the problem I'm seeing is that when building in VS, I need the shim DLLs to be signed by Microsoft - so I'm not sure that Xamarin can provide the shim DLLs without Microsoft? Or have I got this wrong?

If you need the Shim DLLs, then both the System.Net and System.Windows are available MS-PL in the MvvmCross source - or I'm happy to use a different license if that helps

Comment 3 Rolf Bjarne Kvinge [MSFT] 2012-10-30 08:00:53 UTC
I believe you can delay-sign the shim assembly so that the compiler doesn't complain (but it would fail if used with their runtime).
Comment 4 Stuart Lodge 2012-11-10 15:02:40 UTC
I've tried to get this working...

But I just don't really know what I'm doing here...

So I'm going to put a pre-built dll in place that others can use with mvvmcross.

If there's anything I can do to put PCL support a bit higher on the Xamarin's priority list, then please let me know. I'll also keep trying to work with dsplaisted and davkean to keep Microsoft assisting in this process

Thanks - and sorry for being incompetent at delay-signing and certificate-digging...

Comment 5 Stuart Lodge 2012-11-22 03:53:28 UTC
We have a solution to this - or at least a very good workaround now - see @dsplaisted's notes in http://slodge.blogspot.co.uk/2012/11/thanksgiving-post-thanks-for-more.html - checked in to https://github.com/slodge/MvvmCross/commit/f6a88048467838e5ac5ca687744dc0b2d1958aa8.


So we can close this issue now if you like :)


Alternatively... I'd still be interested in somehow getting these Shim DLLs back into MonoDroid (and MonoTouch) somehow at some point if there's any interest.


Comment 6 Stuart Lodge 2012-11-23 09:47:31 UTC
Correction: we have a solution to the strong naming part of this bug report.

The other part - the friend access for System.Net - we only have a rather nasty workaround for - we basically have to build the dll and then rename it - which means that the project referencing doesn't work as well (http://forums.xamarin.com/discussion/195/building-a-system-net-surrogate-dll-under-monotouch-avoiding-a-friend-access-clash#latest)
Comment 7 Stuart Lodge 2013-05-28 13:05:52 UTC

Given the imminent release of PCL support... is there any update on this?

Comment 8 Jonathan Pryor 2013-05-28 14:37:39 UTC
The forthcoming 4.7.6 release will have improved PCL support, but I don't think that it'll be "complete" PCL support...
Comment 9 Rolf Bjarne Kvinge [MSFT] 2013-05-28 16:43:10 UTC
Martin, I believe this is your area now.
Comment 10 Martin Baulig 2013-07-03 10:10:26 UTC
The latest Mono 3.0.12 contains these assemblies, so you don't need to compile them yourself anymore.

If you still want to build them manually, look at how I implemented it here:

Note You need to log in before you can comment on or make changes to this bug.