Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - DataContract with DateTime field gives error

 
 
Old 03-04-2006   #1 (permalink)
iwan.bel@gmail.com


 
 

DataContract with DateTime field gives error

Hi all,

I try to get my fingers around the Hands-On Labs for WCF.
One of the samples uses the following DataContract:

[DataContract(NameSpace="Fabrikam", Name="Trade")]
public class Trade
{
[DataMember]
public string Symbol;
[DataMember]
public long? Count;
[DataMember]
public DateTime? Date;
}

The Service contract has the following Operation:

void AddTrade(Trade trade);

While implementing the functionality and setting the ServiceBehaviour
of the service implementation to (ReturnUnknownExceptionsAsFaults =
true) results in the following error:

System.ServiceModel.UnknownFaultException: The added or subtracted
value results in an un-representable DateTime.

Does anyone has an idea about the cause?

I have the WinFX Jan CTP.

Thanks in advanche,
Iwan Bel


My System SpecsSystem Spec
Old 03-04-2006   #2 (permalink)
Marc Falesse


 
 

Re: DataContract with DateTime field gives error

Iwan,

instead of "DateTime.Now" you should use :

new DateTime(
DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day,
DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second,
DateTime.Now.Millisecond);

or more simply:

new DateTime(DateTime.Now.Ticks);


Adi a écrit :
> I can't find the blog entry now, but there is a known bug with datetime in
> Jan CTP (I suppose you enter "DateTime.Now" as value).
> As far as I recall, you should try using UTC instead, or assign only a date
> as a value.
>
> <iwan.bel@gmail.com> wrote in message
> news:1141050026.529330.44100@i40g2000cwc.googlegroups.com...
>
>>Hi all,
>>
>>I try to get my fingers around the Hands-On Labs for WCF.
>>One of the samples uses the following DataContract:
>>
>>[DataContract(NameSpace="Fabrikam", Name="Trade")]
>>public class Trade
>>{
>> [DataMember]
>> public string Symbol;
>> [DataMember]
>> public long? Count;
>> [DataMember]
>> public DateTime? Date;
>>}
>>
>>The Service contract has the following Operation:
>>
>>void AddTrade(Trade trade);
>>
>>While implementing the functionality and setting the ServiceBehaviour
>>of the service implementation to (ReturnUnknownExceptionsAsFaults =
>>true) results in the following error:
>>
>>System.ServiceModel.UnknownFaultException: The added or subtracted
>>value results in an un-representable DateTime.
>>
>>Does anyone has an idea about the cause?
>>
>>I have the WinFX Jan CTP.
>>
>>Thanks in advanche,
>>Iwan Bel
>>

>
>
>

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Error in Status Field of Printer Vista print fax & scan
Re: error converting object to datetime array element from sql table PowerShell
Rounding of a [datetime] PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46