Vijay Krishna's Notes http://vijaykrishna.posterous.com Most of my notes as a student of computer software and everything around it. posterous.com Mon, 31 Jan 2011 18:16:05 -0800 NameValueCollection and Proxies http://vijaykrishna.posterous.com/namevaluecollection-and-proxies http://vijaykrishna.posterous.com/namevaluecollection-and-proxies Today i learnt yet another painful lesson at work. When you generate a service proxy using SvcUtil, the NameValueCollection data type does not get parsed. In my case it parsed it into a ArrayOfXElement object type by creating  a System.Collections.Specialized namespace within the proxy. I Googled around, then asked around, thinking that i missed some basic object type in c# (read ArrayOfXElement). But that was thankfully not the case. I found a lot of workaround for the given issue. Many involved writing a simple parser (as a wrapper, don't get worried). But a simpler and wiser approach was not to use a NameValueCollection in the first place. Use a Dictionary instead. The same issue comes up in the event of a ArrayList it seems. Use a List object for that. After a little bit of googling i found that the NameValueCollection and the Arraylist are Week Types. According to this discussion thread: http://stackoverflow.com/questions/939118/wcf-serialization-problem-using-namevaluecollection Week types and Weekly typed are two different things. How and why are questions which i am still trying to resolve. But the big and small is this: Do not use NameValueCollections, its an unnecessary headache.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1369599/pic.jpeg http://posterous.com/users/hcGXxsTkwP6SS Vijay Krishna Palepu vpalepu Vijay Krishna Palepu