By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Problem in passing System.Nullable<DateTime>

P: n/a
Hello Group,

(tech: C#, VS2005)

I'm facing a problem in passing Nullable<DateTimeto a webservice.
Below is code in webservice wrapper (reference.cs) used set/get date.

When i set date value

WS.PropertyDateTime = DateTime.Now();
WS.Execute(); //call webmethod
The code fails saying "Date value is of wring type".

private System.Nullable<DateTimemyDateTime;

[System.Xml.Serialization.XmlElementAttribute(IsNul lable=true)]
public System.Nullable<DateTimePropertyDateTime {
get {
return this.myDateTime;
}
set {
this.myDateTime = value;
}
}
But when i remove System.Nullable everything works fine without any
error.
Code:

private DateTime myDateTime;
[System.Xml.Serialization.XmlElementAttribute(IsNul lable=false)]
public DateTime PropertyDateTime {
// same code as above
}

So, here are my questions:
1) Is it advisable to change code in webservice wrapper class
(referrence.cs)
2) if Not then how can solve this problem.

I tried passing date in various formats, used xmlConvert, setting
(IsNullable=false) in client class using propertyInfo etc. But nothng
helped.

Please suggest.

-Thanks

Jul 5 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.