SeyoS
SeyoS

Reputation: 681

Stacktrace shows funcion call that is not directly present in failing method

I have a website used by several person and only one person experiences a bug with a strange stacktrace :

System.FormatException: String was not recognized as a valid datetime. at System.DateTime.Parse(String s, IFormatProvider provider) at EditMandate.getFormData()`.

The strange thing is that there is no parse in the function getFormData. This function uses functions which uses DateTime.Parse but it doesn't use it directly.

Why stack trace shows function that is not directly called by my method?

Also, there is nothing strange in the string being parse as it worked several times and randomly crashed !

Upvotes: 0

Views: 91

Answers (2)

BgrWorker
BgrWorker

Reputation: 679

If the problem arises with just one user, it's probably that person's culture settings on its local machine. Check if his settings have something weird (different date and time separators, 24H or 12H format and so on) and try to always standardize the datetime string you recieve from the client before parsing it.

Upvotes: 1

Jon Skeet
Jon Skeet

Reputation: 1502296

I suspect that:

  • The reason for the problem is due to some broken culture-specific settings on the one person's machine, e.g. a culture which uses an invalid DateTimeFormatInfo.ShortDatePattern
  • The reason the direct stack frame isn't showing is that the JIT is inlining the method which calls DateTime.Parse

Try to find anything which modifies cultures, or anything "different" about this person's machine.

Upvotes: 4

Related Questions