DataContract Problem in WCF Proxies

writing this post after a long time , i was busy in my project so coludn’t make it continue, but in last few days , i have explored many new things .As usual wanna share a very interesting but very rare problem in WCF proxies .
So lets come to the point ..

Sometime what happens , when we generate proxy of a WCF Service than some addition fields also get added in it by the name of “FieldNameSpecified” , The type of this field is of “bool”. An d now the interesting part , Say your property in your dataContratct
is “Date” and in
Proxy file additional field generated is <span
style=”font-weight:bold;”>”DateFieldSpecified”. Now if you don’t set this bool
property to “True” the value assigned to Date property will not pass
through to the service and the default values will be set in Date

Why is it so ?

Actually whenver we are having
working environment for .Net1.1 and .Net2.0 and .Net3.0 framework, than
VS2005 creates the proxy which worked for all the framework.
Now in .Net1.1 we dont have “null” type which can be assigned to a value type, i.e we can write
int x= null;
in .Net2.0 and .Net.3.0 we can , so at the time of proxy generation we
cant decide that value of Date property will null of what , so if “DateFieldSpecified” field sets True that it set the provided value else sets the MinVal or Default value but not “null”.

Does it create a problem anyways ?
It doesnot create any problem , not even at the time of Serialization or Deserialization, because in proxy file when you observe carefully , [XmlIgnoreAttribute], is assigned which stops it in to be counted in Serialization or in Deserialization.

So not to worry, to avoid it use SVCUtil.exe<span
tool provided
with VS2005, and if its still there than you just need to set its value
tom True.

Enjoy WCF ….


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s