Unable to fetch app definition. Error:The string was not recognized as a valid DateTime. There is an unknown word starting at index 0./n

my application show this error. How to deal with this ?

0 3 633
3 REPLIES 3

As the error states, there is some data value that is not correctly formatted to be recognized as a proper DateTime. Based on the fact that it is happening during app fetch, it is likely data in your data source - sheet or database.

Somewhere, the message likely tells you which column. If not then check the data in each Date column of your data source to verify it is in the correct format. Correct or remove any that are bad and then try reloading the app.

Thanks

Parsing a string representation of a c# DateTime is a tricky thing because different cultures have different date formats. .Net is aware of these date formats and pulls them from your current culture (System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat) when you call DateTime.Parse(this.Text); You can either call DateTime.ParseExact and pass in the exact format string that you're expecting, or you can pass in an appropriate culture to DateTime.Parse to parse the date.

For example, this will parse your date correctly:

DateTime.Parse( "22/11/2009", CultureInfo.CreateSpecificCulture("fr-FR") );

Of course, you shouldn't just randomly pick France, but something appropriate to your needs.

What you need to figure out is what System.Threading.Thread.CurrentThread.CurrentCulture is set to, and if/why it differs from what you expect. The IFormatProvider parameter specifies the culture to use to parse the date. Unless your string comes from the user, you should pass CultureInfo.InvariantCulture. If the string does come from the user, you should pass CultureInfo.CurrentCulture, which will use the settings that the user specified in Regional Options in Control Panel.

 

Top Labels in this Space