473,394 Members | 1,878 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 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 10882
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(); }
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.