views:

149

answers:

2

I have a .NET 2.0 website that is periodically losing the value for the DateTimeFormatInfo.CurrentInfo.AMDesignator (or PMDesignator) property. This causes code such as Now.ToString() or even Now.ToString("dd/MM/yyyy hh:mm tt") to not properly display the AM/PM designation which then causes date validation to fail. This issue happens sporadically with no sign of when it's about to happen.

During an occurence of the issue when AM was not showing, I confirmed that the CurrentCulture is not being set to something other than the expected "en-US". I also found that the AMDesignator was blank while the PMDesignator would still be populated correctly. I have also confirmed that I can programmatically reset the AMDesignator of the current running thread by resetting the CurrentCulture. However, I would ultimately like to know the root cause.

The issue seems to be resolved by performing an IISReset on the server. I have also confirmed that this does not affect the rest of the .NET framework by running the same test code through a console app on the server. This leads me to believe that it only affects the web sites running in IIS.

Not sure if it helps, but the .NET framework version is 2.0.50727.832 and the OS version is Windows NT 5.2.3790 SP2.

Any help you can offer would be greatly appreciated. Thanks!

+1  A: 

If you are working with different cultures (e.g. if each user can select his preferred culture), then you have to make sure that you set the current thread's culture at the beginning of every request.

Although, from your description, it seems you are already doing this.

M4N
Yea, thanks for you response Martin. I can programmatically reset the culture of the thread and that seems to correct it, but i still have no idea how the issue happens in the first place
msutandi
A: 

msutandi, I was wondering if you were ever able to find the root cause of this issue. I am still encountering pretty much the exact same problem.

Thanks for your help.

Derry
We repaired the 2.0 framework and installed 3.0 and 3.5. We havent had any issues in the past couple months. You may want to give this a try. good luck
msutandi