Persian Date Format setting not exists in web/user.config

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
7/17/2010 12:14:45 PM
Gravatar
Total Posts 550

Persian Date Format setting not exists in web/user.config

Hi Joe,

Nowadays I receive some emails on Persian Community about incorrect display Persian Date format in new version . I trace to find what happens. I see we have a setting ( WebConfigSettings.UseCustomHandlingForPersianCulture ) in WebConfigSettings class that return false becuase   the UseCustomHandlingForPersianCulture there isn't in web.config. I add it and set it to true , all things work fine.

Best,

Asad

7/17/2010 1:45:04 PM
Gravatar
Total Posts 18439

Re: Persian Date Format setting not exists in web/user.config

Hi Asad,

I will add the setting so it is easy to find in Web.config but for now I will make it false by default.

If you enable this feature under .NET 4, it throws a null exception from your GetPersianCulture method in mojoPortal.Web.Framework.CultureHelper.cs.

Can you try to fix this?

you can keep the current implementation for .NET 3.5 if needed by wrapping it in

#if NET35

 

#endif

Best,

Joe

7/17/2010 2:03:33 PM
Gravatar
Total Posts 550

Re: Persian Date Format setting not exists in web/user.config

Hi Joe,

Yes, I try it now.

Best,

Asad

7/17/2010 5:18:29 PM
Gravatar
Total Posts 550

Re: Persian Date Format setting not exists in web/user.config

Hi Joe,

I thinks no need following code in .NET4. I comment these and all things work fine when I set version of ASP.NET to 4 in my local IIS.

 //typeof(DateTimeFormatInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(info, cal);

//object obj = typeof(DateTimeFormatInfo).GetField("m_cultureTableRecord",
  //              BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info);

     //       obj.GetType().GetMethod("UseCurrentCalendar",
       //         BindingFlags.NonPublic | BindingFlags.Instance).Invoke(obj, new object[] { cal.GetType().GetProperty("ID", BindingFlags.Instance | //BindingFlags.NonPublic).GetValue(cal, null) });

      //      typeof(CultureInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(persianCulture, cal);
       //     typeof(CultureInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(persianCulture, cal);


 I going to sleep. I test more it in all feature tomorrow.

Best,

Asad


 

7/18/2010 9:49:04 AM
Gravatar
Total Posts 18439

Re: Persian Date Format setting not exists in web/user.config

Hi Asad,

Thanks for looking into this. Please let me know if it is still needed under 3.5 .NET or if it can be removed completely. If needed we can keep it for 3.5 but remove it for 4.0 .NET.

Best,

Joe

7/18/2010 10:03:11 AM
Gravatar
Total Posts 550

Re: Persian Date Format setting not exists in web/user.config

Hi Joe,

Yes. Under .NET 3.5 it is needs. I wrapped it by #ifNET35      #endif , but when I debug it in the mojoportal.mssqlonly.net35.sln it don't executed.

Best,

Asad

7/18/2010 10:59:13 AM
Gravatar
Total Posts 18439

Re: Persian Date Format setting not exists in web/user.config

Hi Asad,

Ok, I did it a different way with another config setting instead of the compiler flag. To use the #if NET35 would have required creating a bunch of new projects because then we would need different versions of mojoPortal.Web.Framework project and a few others fo .NET 4.0 to be different.

If you revert your changes and get the latest code from the repository it should be fixed now like this:

// 2010-07-18 this part throws an error under .NET 4, Asad says it is still needed for 3.5
            if (ConfigHelper.GetBoolProperty("UseNet35PersianHelper", false)) //this setting is true in the We.config for 3.5 .NET but not 4.0
            {
                typeof(DateTimeFormatInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(info, cal);

                object obj = typeof(DateTimeFormatInfo).GetField("m_cultureTableRecord",
                    BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).GetValue(info);

                obj.GetType().GetMethod("UseCurrentCalendar",
                    BindingFlags.NonPublic | BindingFlags.Instance).Invoke(obj, new object[] { cal.GetType().GetProperty("ID", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(cal, null) });

                typeof(CultureInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(persianCulture, cal);
                typeof(CultureInfo).GetField("calendar", BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic).SetValue(persianCulture, cal);
            }

I have set UseNet35PersianHelper as true in the Web.net35.config, and I set UseCustomHandlingForPersianCulture as true in both versions of Web.config

Thanks,

Joe

You must sign in to post in the forums. This thread is closed to new posts.