Question

I have a PCL that targets .NET Framework 4.5, Windows 8, WP Silverlight 8, Xamarin Android and Xamarin iOS.

I am referencing it from a 4.5.1 web project.

Upon compilation, where I use an extension method declared in my PCL on XContainer I am getting the following errors:

Error 7 Instance argument: cannot convert from 'System.Xml.Linq.XContainer' to 'System.Xml.Linq.XContainer'

Error 6 The type 'System.Xml.Linq.XContainer' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml.XDocument, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

Why can't I reference and use the PCL if its targeting a down-level .NET version on the same (updated for 4.5) 4.0 CLR?

Reference http://msdn.microsoft.com/en-us/library/bb822049(v=vs.110).aspx

Thanks - Luke

Was it helpful?

Solution

It looks like the library you are referencing needs a particular version of XDocument, and the project you are adding the reference to has a newer version. Alternatively the project you are adding the reference to doesn't have a reference to XDocument at all.

In the first scenario, you need to remove the current version of XDocument from the project you are running (the .net 4.5.1 project) and add the correct version (version 4.0.0.0).

If it's the second, you need to add XDocument to this project, and ensure you add the correct version.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top