I'm trying to make a portable class library in VS2010. By default, it seems to be targeting .NET Framework 4 and higher
. I need to target 4.03 or higher because I need some features that were added (System.Xml.Linq
). But when I try to change the target framework, the change doesn't work. I get this dialog:
I can choose one of the other frameworks and say OK
, but when I look again, it's set back to the same Framework 4.0 setting, and my code using the 4.03 features still doesn't compile. What's going on here?
Update: It does let me choose 4.5 as long as I don't choose Mono for Android
or VS Mono Touch
. It looks like something in those libraries requires 4.0, but I don't understand why, since 4.5 is backwards compatible. And this is for use in Mono, so I need those.
I figured this out with some hacking of the configuration files for the portable framework. First, read this post about how to add library support for PCL's for MonoDroid and this one to do a similar thing for MonoTouch.
In the .csproj file for the PCL project, I found this line:
<TargetFrameworkProfile>Profile95</TargetFrameworkProfile>
which points to this folder:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.0\Profile\Profile95
In that folder, there's a subfolder called SupportedFrameworks
and this was missing the magic files MonoAndroid,Version=v1.6+.xml
and VSMonoTouch,Version=v1.0+.xml
. I added these, as described in the linked post, and now it works.