Bug 37203 - Failed to resolve "System.Runtime.Serialization.XsdDataContractExporter"
Summary: Failed to resolve "System.Runtime.Serialization.XsdDataContractExporter"
Alias: None
Product: iOS
Classification: Xamarin
Component: MSBuild ()
Version: XI 9.4 (iOS 9.2)
Hardware: PC Windows
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-12-21 17:31 UTC by Caan Mee
Modified: 2015-12-22 14:02 UTC (History)
2 users (show)

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

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description Caan Mee 2015-12-21 17:31:19 UTC
I currently struggle to build our project after update to Xamarin 4.

I always see the following linker error:
    2>C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(664,3): error : Failed to resolve "System.Runtime.Serialization.XsdDataContractExporter" reference from "System.Runtime.Serialization, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089"
    2>  --- inner exception
    2>  Mono.Cecil.ResolutionException: Failed to resolve System.Runtime.Serialization.XsdDataContractExporter
    2>    at Mono.Linker.Steps.MarkStep.MarkType (Mono.Cecil.TypeReference reference) <0x1118dcc40 + 0x004c2> in <filename unknown>:0 
    2>    at Xamarin.Linker.Steps.MobileMarkStep.MarkType (Mono.Cecil.TypeReference reference) <0x1118dc470 + 0x0004a> in <filename unknown>:0 
    2>    at Xamarin.Linker.Steps.CoreMarkStep.MarkType (Mono.Cecil.TypeReference reference) <0x1118dc000 + 0x0006c> in <filename unknown>:0 
    2>    at MonoTouch.Tuner.MonoTouchMarkStep.MarkType (Mono.Cecil.TypeReference reference) <0x1118dbf00 + 0x0001f> in <filename unknown>:0 
    2>    at Mono.Linker.Steps.MarkStep.MarkField (Mono.Cecil.FieldReference reference) <0x1118def20 + 0x000e9> in <filename unknown>:0 
    2>    at Mono.Linker.Steps.MarkStep.InitializeFields (Mono.Cecil.TypeDefinition type) <0x1128b6780 + 0x000ad> in <filename unknown>:0 
    2>    at Mono.Linker.Steps.MarkStep.InitializeType (Mono.Cecil.TypeDefinition type) <0x1118dbd30 + 0x00069> in <filename unknown>:0 
    2>    at Mono.Linker.Steps.MarkStep.InitializeAssembly (Mono.Cecil.AssemblyDefinition assembly) <0x1118d8f90 + 0x000cf> in <filename unknown>:0 
    2>    at MonoTouch.Tuner.MonoTouchMarkStep.InitializeAssembly (Mono.Cecil.AssemblyDefinition assembly) <0x1118d8f20 + 0x0001f> in <filename unknown>:0 
    2>    at Mono.Linker.Steps.MarkStep.Initialize () <0x1118d8e80 + 0x00063> in <filename unknown>:0 
    2>    at Mono.Linker.Steps.MarkStep.Process (Mono.Linker.LinkContext context) <0x1118d8de0 + 0x00052> in <filename unknown>:0 
    2>    at Xamarin.Linker.Steps.MobileMarkStep.Process (Mono.Linker.LinkContext context) <0x1118d8b70 + 0x00044> in <filename unknown>:0 
    2>    at Xamarin.Linker.Steps.CoreMarkStep.Process (Mono.Linker.LinkContext context) <0x1118d88e0 + 0x000de> in <filename unknown>:0 
    2>    at MonoTouch.Tuner.MonoTouchMarkStep.Process (Mono.Linker.LinkContext context) <0x1118d8790 + 0x0006c> in <filename unknown>:0 
    2>    at Mono.Linker.Pipeline.Process (Mono.Linker.LinkContext context) <0x110bd9f30 + 0x000eb> in <filename unknown>:0 
    2>    at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1& assemblies) <0x110bd59c0 + 0x00277> in <filename unknown>:0 
    2>  ---
    2>    at MonoTouch.Tuner.Linker.Process (MonoTouch.Tuner.LinkerOptions options, MonoTouch.Tuner.MonoTouchLinkContext& context, System.Collections.Generic.List`1& assemblies) <0x110bd59c0 + 0x005dd> in <filename unknown>:0 
    2>    at MonoTouch.Target.LinkAssemblies (System.String main, System.Collections.Generic.List`1& assemblies, System.String output_dir, MonoTouch.Tuner.MonoTouchLinkContext& link_context) <0x110bd4530 + 0x0051c> in <filename unknown>:0 
    2>    at MonoTouch.Target.ManagedLink () <0x110bd1670 + 0x009ae> in <filename unknown>:0 
    2>    at MonoTouch.Target.ProcessAssemblies () <0x110bd1090 + 0x0034f> in <filename unknown>:0 
    2>    at MonoTouch.Application.BuildApp () <0x110bd0760 + 0x000af> in <filename unknown>:0 
    2>    at MonoTouch.Application.Build () <0x1106e7580 + 0x000ee> in <filename unknown>:0 
    2>    at MTouch.Main2 (System.String[] args) <0x10dfd2230 + 0x074c7> in <filename unknown>:0 
    2>    at MTouch.Main (System.String[] args) <0x10dd10e60 + 0x00069> in <filename unknown>:0 
    ========== Build: 1 succeeded, 1 failed, 16 up-to-date, 0 skipped ==========

I already added linkskip options:
 --linkskip=System.Runtime --linkskip=System.Runtime.Serialization --linkskip=System.Core

But I'm unable to build our project with "Link SDK Assemblies only", turning linking off, of course solves this problem.
Comment 1 Sebastien Pouliot 2015-12-21 20:26:51 UTC
> System.Runtime.Serialization.XsdDataContractExporter" reference from "System.Runtime.Serialization, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089

^ this is incorrect. You have one (or more) assembly binary that refers to a desktop version of .NET, not the one that we ship with Xamarin.iOS (which use the "" version string).

Using an incorrect assembly means you can end up with references to missing types, like `XsdDataContractExporter` which is not something we ship in the mobile profile. The linker cannot re-write an assemblies with missing pieces, turning it off only makes this a runtime issue.

To solve this your project, and it's dependencies, needs to use the BCL from the SDK shipped with Xamarin.iOS or one of the supported PCL profiles.

note: if you need help to track down where the reference comes from please attach a test case to the bug report and we'll have a look.
Comment 2 Caan Mee 2015-12-22 14:02:47 UTC
Thanks for the explanation.

Currently tracking down the references in our projects.