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.
When an unhandled exception occurs in a remote webservice method MonoTouch raises the following error:
Message: DataMember property 'System.String Message' on type 'System.ServiceModel.ExceptionDetail' must have both getter and setter.
at System.Runtime.Serialization.SharedContractMap.GetMembers (System.Type type) [0x0007d] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:471
at System.Runtime.Serialization.SharedContractMap.Initialize () [0x00040] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:449
at System.Runtime.Serialization.KnownTypeCollection.RegisterContract (System.Type type) [0x0004e] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:919
at System.Runtime.Serialization.KnownTypeCollection.DoTryRegister (System.Type type) [0x00046] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:745
at System.Runtime.Serialization.KnownTypeCollection.TryRegister (System.Type type) [0x0000c] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:723
at System.Runtime.Serialization.KnownTypeCollection.InsertItem (Int32 index, System.Type type) [0x00019] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/KnownTypeCollection.cs:466
at System.Collections.ObjectModel.Collection`1[System.Type].Add (System.Type item) [0x0000c] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Collections.ObjectModel/Collection.cs:74
at System.Runtime.Serialization.DataContractSerializer.RegisterTypeAsKnown (System.Type type) [0x00026] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:238
at System.Runtime.Serialization.DataContractSerializer.PopulateTypes (IEnumerable`1 knownTypes) [0x00058] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:226
at System.Runtime.Serialization.DataContractSerializer..ctor (System.Type type, IEnumerable`1 knownTypes) [0x00029] in /Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:74
at System.Runtime.Serialization.DataContractSerializer..ctor (System.Type type) [0x00000] in <filename unknown>:0
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request (System.ServiceModel.Description.OperationDescription od, System.Object parameters) [0x00110] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:541
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess (System.Reflection.MethodBase method, System.String operationName, System.Object parameters) [0x00038] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:486
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process (System.Reflection.MethodBase method, System.String operationName, System.Object parameters) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:466
I'm am getting this same error when the service tries to use a FaultContract as well.
I have solved the initial problem, the Linker was removing the property on ExceptionDetail. I turned off linking and the unhandled exception correctly flows through.
I am still getting some issues with FaultContracts, but that would be a different problem.
Should the ExceptionDetail class have Preserve(AllMembers=true) ?
I've been considering (among other things ;-) to add automatic protection to [DataMember] decorated properties. I think this makes it clear it's something needed (since it affects "Link SDK") . Thanks a lot for spotting (and reporting) this!
Ok to fix this without turning off the Linker I included the following within my code:
var x = new System.ServiceModel.ExceptionDetail(new Exception());
if (x.InnerException == null || x.StackTrace == null || x.Type == null || x.HelpLink == null)
I didn't have to reference the Message property within the if statement, but perhaps that should be there as well for completeness.
In addition to my last comment, I had to actually perform a dummy operation within that If statement, otherwise it got optimized out :)
Thanks for the extra details Justin!
Do you have a small test case on which I'll be able to test my fix (beside simply ensuring the type/members are not removed from the assembly) ?
I'm testing a smarter linker rule wrt serialization (both DataContract and XmlSerialization).
In the mean time you can also add "--linkskip=System.ServiceModel" (in "additional mtouch arguments") as a less intrusive (as in "no code to add" but likely a bigger final .app) option.
Fixed. Smarter linking coming in the next minor (non-bug fix) version.