472,780 Members | 1,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

Error converting DateTime in WebService Method parameter

Hi,

I have a web service method which takes a DateTime type as a parameter.
The service is UK based, and the dates are passed in to the service in the
UK format dd/MM/yyyy.

On a recent install, the web service method will not accept the UK date
format, erroring with a System.Argument exception, but would take US
formatted dates.

As the DateTime type is a method parameter, I cannot use an IFormatProvider
to Parse the date, and check for any errors. What appears to be happening is
that the Web Service code which runs before my method code runs is trying to
Parse the date, but why would it choose US date?

All locale settings on the machine are English (United Kingdom). I have
checked all the the registry entries under HKU -S....... -Control Panel
-International, and they are all set to English (United Kingdom). I have
also set the globalization element in the web.config file for both the
CurrentCulture and CurrentUICulture to en-GB.

So this appears to be the .NET framework code, perhaps as a result of the
[WebMethod] attribute, deserializing the date, and attempting to create a
DateTime object on behalf of the method, but why is it choosing the en-US
method??

Stack Trace

System.ArgumentException: Cannot convert 31/03/2006 to System.DateTime.
Parameter name: type ---System.FormatException: String was not recognized
as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi,
DateTimeStyles styles)
at System.DateTime.Parse(String s, IFormatProvider provider)
at System.Convert.ToDateTime(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToDateTime(IForm atProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at System.Web.Services.Protocols.ScalarFormatter.From String(String value,
Type type)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.ScalarFormatter.From String(String value,
Type type)
at
System.Web.Services.Protocols.ValueCollectionParam eterReader.Read(NameValueCollection collection)
at System.Web.Services.Protocols.HtmlFormParameterRea der.Read(HttpRequest
request)
at System.Web.Services.Protoco

Any help would be greatly appreciated.

Rich
Jul 12 '06 #1
3 10832
Hi Rich,

Did you check the culture infor for the current thread ?.

System.Globalization.CultureInfo ci =
System.Threading.Thread.CurrentThread.CurrentCultu re;

If that CultureInfo instance is US, some globalization setting is not being
applied correctly in your application.

Regards,
Pablo Cibraro
http://weblogs.asp.net/cibrax
[MVP - Connected Systems Developer]

"Rich Robinson" <Rich Ro******@discussions.microsoft.comwrote in message
news:84**********************************@microsof t.com...
Hi,

I have a web service method which takes a DateTime type as a parameter.
The service is UK based, and the dates are passed in to the service in the
UK format dd/MM/yyyy.

On a recent install, the web service method will not accept the UK date
format, erroring with a System.Argument exception, but would take US
formatted dates.

As the DateTime type is a method parameter, I cannot use an
IFormatProvider
to Parse the date, and check for any errors. What appears to be happening
is
that the Web Service code which runs before my method code runs is trying
to
Parse the date, but why would it choose US date?

All locale settings on the machine are English (United Kingdom). I have
checked all the the registry entries under HKU -S....... -Control
Panel
-International, and they are all set to English (United Kingdom). I have
also set the globalization element in the web.config file for both the
CurrentCulture and CurrentUICulture to en-GB.

So this appears to be the .NET framework code, perhaps as a result of the
[WebMethod] attribute, deserializing the date, and attempting to create a
DateTime object on behalf of the method, but why is it choosing the en-US
method??

Stack Trace

System.ArgumentException: Cannot convert 31/03/2006 to System.DateTime.
Parameter name: type ---System.FormatException: String was not
recognized
as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi,
DateTimeStyles styles)
at System.DateTime.Parse(String s, IFormatProvider provider)
at System.Convert.ToDateTime(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToDateTime(IForm atProvider
provider)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at System.Web.Services.Protocols.ScalarFormatter.From String(String
value,
Type type)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.ScalarFormatter.From String(String
value,
Type type)
at
System.Web.Services.Protocols.ValueCollectionParam eterReader.Read(NameValueCollection
collection)
at
System.Web.Services.Protocols.HtmlFormParameterRea der.Read(HttpRequest
request)
at System.Web.Services.Protoco

Any help would be greatly appreciated.

Rich

Jul 17 '06 #2
Hi,

I have a web service method which takes a DateTime type as a parameter.
The service is UK based, and the dates are passed in to the service in the
UK format dd/MM/yyyy.

On a recent install, the web service method will not accept the UK date
format, erroring with a System.Argument exception, but would take US
formatted dates.

As the DateTime type is a method parameter, I cannot use an IFormatProvider
to Parse the date, and check for any errors. What appears to be happening is
that the Web Service code which runs before my method code runs is trying to
Parse the date, but why would it choose US date?

All locale settings on the machine are English (United Kingdom). I have
checked all the the registry entries under HKU -S....... -Control Panel
-International, and they are all set to English (United Kingdom). I have
also set the globalization element in the web.config file for both the
CurrentCulture and CurrentUICulture to en-GB.

So this appears to be the .NET framework code, perhaps as a result of the
[WebMethod] attribute, deserializing the date, and attempting to create a
DateTime object on behalf of the method, but why is it choosing the en-US
method??

Stack Trace

System.ArgumentException: Cannot convert 31/03/2006 to System.DateTime.
Parameter name: type ---System.FormatException: String was not recognized
as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi,
DateTimeStyles styles)
at System.DateTime.Parse(String s, IFormatProvider provider)
at System.Convert.ToDateTime(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToDateTime(IForm atProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at System.Web.Services.Protocols.ScalarFormatter.From String(String value,
Type type)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.ScalarFormatter.From String(String value,
Type type)
at
System.Web.Services.Protocols.ValueCollectionParam eterReader.Read(NameValueCollection collection)
at System.Web.Services.Protocols.HtmlFormParameterRea der.Read(HttpRequest
request)
at System.Web.Services.Protoco

Any help would be greatly appreciated.

Rich
I have the samo error in my multilanguage aplication.
i got this error when i receave data like this 10.23.2006 or 10/23/2006 so i did something simple.Just change the place of Month and Day (from 10.23.2006 to 23.10.2006) and i have no more this problem :P

Posted from http://www.topxml.com/renntp using reNNTP: the website based NNTP reader.
Aug 10 '06 #3
Is the client computer configured for US English?

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#
"Rich Robinson" wrote:
Hi,

I have a web service method which takes a DateTime type as a parameter.
The service is UK based, and the dates are passed in to the service in the
UK format dd/MM/yyyy.

On a recent install, the web service method will not accept the UK date
format, erroring with a System.Argument exception, but would take US
formatted dates.

As the DateTime type is a method parameter, I cannot use an IFormatProvider
to Parse the date, and check for any errors. What appears to be happening is
that the Web Service code which runs before my method code runs is trying to
Parse the date, but why would it choose US date?

All locale settings on the machine are English (United Kingdom). I have
checked all the the registry entries under HKU -S....... -Control Panel
-International, and they are all set to English (United Kingdom). I have
also set the globalization element in the web.config file for both the
CurrentCulture and CurrentUICulture to en-GB.

So this appears to be the .NET framework code, perhaps as a result of the
[WebMethod] attribute, deserializing the date, and attempting to create a
DateTime object on behalf of the method, but why is it choosing the en-US
method??

Stack Trace

System.ArgumentException: Cannot convert 31/03/2006 to System.DateTime.
Parameter name: type ---System.FormatException: String was not recognized
as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi,
DateTimeStyles styles)
at System.DateTime.Parse(String s, IFormatProvider provider)
at System.Convert.ToDateTime(String value, IFormatProvider provider)
at System.String.System.IConvertible.ToDateTime(IForm atProvider provider)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at System.Web.Services.Protocols.ScalarFormatter.From String(String value,
Type type)
--- End of inner exception stack trace ---
at System.Web.Services.Protocols.ScalarFormatter.From String(String value,
Type type)
at
System.Web.Services.Protocols.ValueCollectionParam eterReader.Read(NameValueCollection collection)
at System.Web.Services.Protocols.HtmlFormParameterRea der.Read(HttpRequest
request)
at System.Web.Services.Protoco

Any help would be greatly appreciated.

Rich
Sep 7 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Justin Wong | last post by:
CREATE PROCEDURE dbo.Synchronization_GetNewRecords ( @item varchar(50), @last datetime ) AS SET NOCOUNT ON
4
by: shyner | last post by:
Hi Everyone, I've been battling this for two days with no luck. I'm using SQL Server 2000. Here's the mystery: I've got a stored procedure that takes a single varchar parameter to determine...
1
by: Philip Townsend | last post by:
I am using the Microsoft Application Data Block and am getting the following error when trying to return a DataSet. Object must implement IConvertible Here is the code where the error occurs:...
7
by: Jorgen Haukland, Norway | last post by:
Hi, I have created a Java webservice which runs in IBM WebSphere appserver. I take the WSDL-file and create a VS.NET WinForm application and calls the service running on my PC and everything...
5
by: BenG | last post by:
Hi. I have a gridview control on a web form (asp.net 2.0) that's bound to a objectDataSource. The objectdatasource which is bound to a class I've written in the DAL to read and update the database....
7
by: jamesas | last post by:
I am wrote the coding for PHP 5 to access tourico holidays webservice. as follows.But it returns the error followed by the code .please help me <?php try{ class authentication_header {...
1
by: =?Utf-8?B?d2R1ZGVr?= | last post by:
I have a web service hosting a WCF library, which works fine but produced a strange signature when interacting with vs 2005/2.0 clients. My method takes 3 strings and returns a bool as below. ...
0
by: umalingesh | last post by:
Hi, I have a .Net webservice which takes a Datetime object as parameter public string GetDateTime(DateTime dt) { return dt.ToString(); }
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.