Sitecore Social Connected – Issue with Different .NET Cultures

Just a quick post to report an issue I came across while testing the Sitecore Social Connected module (version 2.1). Overall it’s a great module but I ran into an issue that will effect you depending on what .NET culture your Sitecore site is running on. For example, I ran into the issue with “en-CA” but everything is fine when using “en-US”. The following error was thrown in the log when attempting to log in using social media credentials for an existing user.

Exception: Sitecore.Social.Infrastructure.Exceptions.SocialException
Message: String was not recognized as a valid DateTime.
Nested Exception
Exception: System.FormatException
Message: String was not recognized as a valid DateTime.
Source: mscorlib

at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at Sitecore.Social.BusinessLogic.Users.UserManager.NeedsToUpdateProfile(User user, Network network)
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Sitecore.Social.BusinessLogic.SocialProfileBusinessManager.RefreshSocialProfiles(IPrincipal user, Boolean refreshAsync, Boolean forceRefresh)
at Sitecore.Social.Client.Api.Connector.ConnectorAuthCompleted.AuthCompleted(AuthCompletedArgs args)

The result of the error is that the user’s social profile information is never updated after their account is first created in Sitecore.

The real cause of the problem is that when the module checks to see if a user needs their social profile data updated, a “DateTime.Parse” call is made that does not make use of “CultureInfo.InvariantCulture”. Since the date in question is stored in the format of “MM/dd/yyyy HH:mm:ss“, the error will be thrown if this format is not valid for the current .NET culture.

As always Sitecore support was quick in resolving the issue and will be able to provide a patch upon request! Unfortunately the class in question is not exposed in a custom config file so the fix was not as straightforward as usual.

Just keep this in mind when using the Sitecore Social Connected module because the issue may not be readily apparent for one language but appear for other languages in a multilingual solution.

Posted in Sitecore, Sitecore Bug, Sitecore Modules

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s