Bug 557 - [WCF] Type not found; name: KeyValuePairOfstringstring, namespace:
Summary: [WCF] Type not found; name: KeyValuePairOfstringstring, namespace:
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 4.x
Hardware: Macintosh Mac OS
: --- major
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2011-08-30 20:50 UTC by Sebastien Pouliot
Modified: 2011-09-06 11:31 UTC (History)
2 users (show)

Tags:
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:
Status:
RESOLVED FIXED

Description Sebastien Pouliot 2011-08-30 20:50:19 UTC
copy/pasted from comment #14 of bug #380 (which was a regression from 3.x)

Ok, I was able to try the new assembly.
Even though it did compile, I am having an error at runtime, while doing a
little bit more of a normal smoke test. Given this error, I have switch back to
the previous assembly you have provided, but the error was also there.

Looks like this is when it tries to serialize the webservice response. Below I
paste a specific class property that is part of the webservice contract:

        private System.Collections.Generic.KeyValuePair<string, string>[]
ValuesField;

        [System.Runtime.Serialization.DataMemberAttribute()]
        public System.Collections.Generic.KeyValuePair<string, string>[] Values
        {
            get
            {
                return this.ValuesField;
            }
            set
            {
                this.ValuesField = value;
            }
        }

Here is the stack trace for more info:

Type not found; name: KeyValuePairOfstringstring, namespace:
http://schemas.datacontract.org/2004/07/System.Collections.Generic

 at System.Runtime.Serialization.XmlFormatterDeserializer.GetTypeFromNamePair
(System.String name, System.String ns) [0x001a6] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:292 
  at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap
(System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader
reader) [0x00076] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:227 
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize
(System.Type type, System.Xml.XmlReader reader) [0x0027a] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:187 
  at System.Runtime.Serialization.SerializationMap.DeserializeContent
(System.Xml.XmlReader reader,
System.Runtime.Serialization.XmlFormatterDeserializer deserializer,
System.String id, Boolean empty) [0x00217] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:347 
  at System.Runtime.Serialization.SerializationMap.DeserializeContent
(System.Xml.XmlReader reader,
System.Runtime.Serialization.XmlFormatterDeserializer deserializer,
System.String id) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:292 
  at System.Runtime.Serialization.SerializationMap.DeserializeObject
(System.Xml.XmlReader reader,
System.Runtime.Serialization.XmlFormatterDeserializer deserializer) [0x0003a]
in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:264 
  at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap
(System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader
reader) [0x000ba] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:234 
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize
(System.Type type, System.Xml.XmlReader reader) [0x0027a] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:187 
  at System.Runtime.Serialization.CollectionTypeMap.DeserializeContent
(System.Xml.XmlReader reader,
System.Runtime.Serialization.XmlFormatterDeserializer deserializer,
System.String id) [0x00064] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:669 
  at System.Runtime.Serialization.SerializationMap.DeserializeObject
(System.Xml.XmlReader reader,
System.Runtime.Serialization.XmlFormatterDeserializer deserializer) [0x0003a]
in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:264 
  at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap
(System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader
reader) [0x000ba] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:234 
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize
(System.Type type, System.Xml.XmlReader reader) [0x0027a] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:187 
  at System.Runtime.Serialization.SerializationMap.DeserializeContent
(System.Xml.XmlReader reader,
System.Runtime.Serialization.XmlFormatterDeserializer deserializer,
System.String id, Boolean empty) [0x00217] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:347 
  at System.Runtime.Serialization.SerializationMap.DeserializeContent
(System.Xml.XmlReader reader,
System.Runtime.Serialization.XmlFormatterDeserializer deserializer,
System.String id) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:292 
  at System.Runtime.Serialization.SerializationMap.DeserializeObject
(System.Xml.XmlReader reader,
System.Runtime.Serialization.XmlFormatterDeserializer deserializer) [0x0003a]
in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/SerializationMap.cs:264 
  at System.Runtime.Serialization.XmlFormatterDeserializer.DeserializeByMap
(System.Xml.XmlQualifiedName name, System.Type type, System.Xml.XmlReader
reader) [0x000ba] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:234 
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize
(System.Type type, System.Xml.XmlReader reader) [0x0027a] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:187 
  at System.Runtime.Serialization.XmlFormatterDeserializer.Deserialize
(System.Xml.XmlReader reader, System.Type declaredType,
System.Runtime.Serialization.KnownTypeCollection knownTypes,
IDataContractSurrogate surrogate,
System.Runtime.Serialization.DataContractResolver resolver,
System.Runtime.Serialization.DataContractResolver defaultResolver,
System.String name, System.String ns, Boolean verifyObjectName) [0x0007e] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlFormatterDeserializer.cs:65 
  at System.Runtime.Serialization.DataContractSerializer.ReadObject
(System.Xml.XmlDictionaryReader reader, Boolean verifyObjectName) [0x00024] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/DataContractSerializer.cs:333 
  at System.Runtime.Serialization.XmlObjectSerializer.ReadObject
(System.Xml.XmlDictionaryReader reader) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/System.Runtime.Serialization/System.Runtime.Serialization/XmlObjectSerializer.cs:74 
  at
System.ServiceModel.Dispatcher.DataContractMessagesFormatter.ReadMessagePart
(System.ServiceModel.Description.MessagePartDescription part,
System.Xml.XmlDictionaryReader r) [0x00000] in <filename unknown>:0 
  at
System.ServiceModel.Dispatcher.DataContractMessagesFormatter.MessageToParts
(System.ServiceModel.Description.MessageDescription md,
System.ServiceModel.Channels.Message message) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.Dispatcher.BaseMessagesFormatter.DeserializeReply
(System.ServiceModel.Channels.Message message, System.Object[] parameters)
[0x00000] in <filename unknown>:0 
  at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeReply
(System.ServiceModel.Channels.Message message, System.Object[] parameters)
[0x00000] in <filename unknown>:0 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request
(System.ServiceModel.Description.OperationDescription od, System.Object[]
parameters) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess
(System.Reflection.MethodBase method, System.String operationName,
System.Object[] parameters) [0x00000] in <filename unknown>:0 
  at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process
(System.Reflection.MethodBase method, System.String operationName,
System.Object[] parameters) [0x00000] in <filename unknown>:0
Comment 1 Sebastien Pouliot 2011-08-30 20:51:54 UTC
add original reporter (from bug #380) on c.c.
Comment 2 Sebastien Pouliot 2011-08-30 20:55:58 UTC
Can you look at your linker settings ? 

Using System.Xml.Serialization often requires using [Preserve] attributes in user code when the linker is set to "Link all". Changing this to "Don't link" (and rebuilding) will confirm if the issue is linker-related or not. Thanks
Comment 3 fdibartolo 2011-08-30 22:47:10 UTC
I gave it another try with the linker set to "Dont link", but unfortunately the bug still persists.
Comment 4 Sebastien Pouliot 2011-08-31 09:40:45 UTC
Ok, we now know it's not linker related. I'll use the above to create a small test case to see if I can duplicate the issue.
Comment 5 fdibartolo 2011-08-31 10:36:04 UTC
I do appreciate your time, please let me know if you need anything from me.
Thanks again.
Comment 6 Sebastien Pouliot 2011-08-31 10:51:28 UTC
I added your [DataMember] inside a [DataContract]

	[DataContract]
	public class Test {
        private System.Collections.Generic.KeyValuePair<string, string>[] ValuesField;

        [DataMemberAttribute]
        public System.Collections.Generic.KeyValuePair<string, string>[] Values
        {
            get
            {
                return this.ValuesField;
            }
            set
            {
                this.ValuesField = value;
            }
        }
	}

and tested both serialization and deserialization

				Test t = new Test ();
				t.Values = new KeyValuePair<string, string> [] { new KeyValuePair<string,string> ("key", "value") };
				StringWriter sw = new StringWriter ();
				XmlSerializer xs = new XmlSerializer (typeof (Test));
				xs.Serialize (sw, t);
				string s = sw.ToString ();
				StringReader sr = new StringReader (s);
				Test nt = (Test) xs.Deserialize (sr);

on both the simulator and the device. Both works, i.e. 'nt' as the same value in the property.

Can you provide me with a test case (small if possible :-) to reproduce this ? (or first try the above if it works for you and the version of MonoTouch you're using). Thanks
Comment 7 fdibartolo 2011-09-01 08:55:04 UTC
Hmm, it is weird for me as well, as not always happens. But what is weird, is that for the same set of data, the first time it deserializes ok, and the second one throws the exception.

Let me try to create a small sample and see if it happens there, and if it does, i can provide that, instead of the main app.

Will get back to you, thanks again.
Comment 8 fdibartolo 2011-09-01 10:26:07 UTC
I am about to email you a sample code where I can reproduce it.
Thanks!
Comment 9 fdibartolo 2011-09-02 15:16:37 UTC
Hey, just wondering if you received my email with the sample code?
Let me know if not, and I can send it again.
Thanks!
Comment 10 Sebastien Pouliot 2011-09-02 16:21:11 UTC
Yep, I got it. I should try it soon. Thanks!
Comment 11 Sebastien Pouliot 2011-09-02 20:16:27 UTC
ok, so the first time I simply clicked many times the button... then realized it must be async and ended the application to check the code.

second time I clicked a single time, waited a bit (more than one minute) and got a NullReferenceException deep in NHibernate code

third time was better, I clicked several times without ever getting an error. The first request were _very_ slow (before Ok! was printed) but the last ones were near-instantaneous. It could be a local (ISP) networking issue or it could be your server load (or both).

Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.dll [External]
Loaded assembly: /Users/sebastienpouliot/Downloads/TestBug557/TestBug557/bin/iPhoneSimulator/Debug/TestBug557.exe
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.ServiceModel.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/Mono.Security.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Runtime.Serialization.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll [External]
Service -> Loading expense
Thread started: 
Thread started: 
Thread started: 
Thread started: 
Thread started: 
Thread started: 
Thread started: 
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!
Service -> Loading expense
Service Response Ok!

So it seems to work (if the above application output makes sense). Giving you a newer System.ServiceModel.dll (without a full runtime/class lib) could have unintended effects, but I can't imagine how it would work one time, then fail ?!?
Comment 12 fdibartolo 2011-09-04 19:50:52 UTC
Cant thank you more for keep looking into this.
So looking at your output, webservice call seems to be working for you. Where you able to see the data printed on the screen?
I still have the same problem, really really weird that the first call runs ok, and then fails upon the second one.

I am currently running monotouch 4.0.7, in addition to the servicemodel.dll that you have provided. Is this the only difference you and I have on each other end? Do you think any other assemblies may be causing this, runtime.serialization.dll (not sure if there is a difference in the assembly that you can tell? 
Let me know if you want me to try a new fresh build that you can pull.

Thanks again!
Comment 13 Sebastien Pouliot 2011-09-05 13:57:41 UTC
> Where you able to see the data printed on the screen?

Yes, some names and numbers were present (but I don't recall them changing between execution). If they are important I can print them for comparison.

> Is this the only difference you and I have on each other end?

No, there are a lot of other differences - in fact almost everywhere except the BCL (few), including WCF (fewer) and none that looks related to this "first time" ok.

Are you able to test the latest 4.1.x (beta) build ? That would include most of the other fixes.

I could ship you other assemblies (like S.R.S.dll) but you'll end up with a "franken-build" where any other issue will be extremely difficult to debug/duplicate (and it's not impossible this issue is caused by a similar issue).
Comment 14 fdibartolo 2011-09-06 07:55:18 UTC
I will try 4.1.x (beta) build as soon as I can and let you know.
Thanks!
Comment 15 fdibartolo 2011-09-06 10:27:58 UTC
Ok, so I have installed 4.1.1.1.
If I rebuild right away, the "bug 380" comes up, the missing prop.
What I did was to replace the servicemodel assembly once again, with the one provided by you before, and then it compiled.
After trying with the demo app, it is working, same thing when I then switch to the main app and try.
(by the way, I saw another problem, but I need to see what that is, and doesnt seem to be related to this).

So, with both the demo and main app, even though it works, what I did notice in the monodevelop application output are stuff like this below, not sure what they are:

[0xb0943000:] EXCEPTION handling: System.Security.Cryptography.CryptographicException: Store Root doesn't exists.
...
[0xb0943000:] EXCEPTION handling: System.Security.Cryptography.CryptographicException: Store CA doesn't exists.
…
[0xb0943000:] EXCEPTION handling: System.ArgumentNullException: Argument cannot be null.
Parameter name: type

Is that something known?
By the way, is bug 380 going to be part of MT 4.2 then?

Thanks a lot again!!
Comment 16 Sebastien Pouliot 2011-09-06 10:41:54 UTC
> If I rebuild right away, the "bug 380" comes up, the missing prop.

Yes, the attached assembly is newer than what MonoTouch 4.1.1.1 provides.


> After trying with the demo app, it is working, same thing when I then switch to
> the main app and try.

Great news :-)


> (by the way, I saw another problem, but I need to see what that is, and doesnt
> seem to be related to this).

Once confirmed please open a new bug report to track it.


> Is that something known?

It's not really an issue. Some recent versions of MonoTouch had extra debugging logging enabled (i.e. --trace=E:all) which shows every exception being thrown (even the "normal", catched ones). This has been removed for 4.2 (since it's a bit confusing). The real reason is that "machine store" cannot exists in iOS.


> By the way, is bug 380 going to be part of MT 4.2 then?

Yep! MonoTouch 4.1.1.1 was branched on August 26th (released 30th), while my fix was pushed on the 29th (see comment #12 inside bug 380). A near miss :(
Comment 17 fdibartolo 2011-09-06 11:31:22 UTC
Good, then I believe we can close the incident.
So until 4.2, I will then have this servicemodel dll handy.

>> (by the way, I saw another problem, but I need to see what that is, and doesnt
>> seem to be related to this).
> Once confirmed please open a new bug report to track it.

I guess this is how I am managing some stuff, and GC now in 4.x is yelling at me. I dont think it is a MT bug, bug will open a new incident if needed.

Thank you once again for your support here.