Hi,
Since few days - after upgrading Umbraco from 7.5.7 to 7.6.1 I am facing issue with FormatException (String was not recognized as a valid DateTime). This happens randomly - from time to time and only for Arabic localization (ar-SA culture). Please find below tracelog. I would appriciate some help with that because it looks like something is wrong with parsing create or update date of IPublishedContent right after it was received from umbraco cache. Thanks in advance
Exception message: String was not recognized as a valid DateTime.
at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache.DictionaryPublishedContent.ParseDateTimeValue(String val)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache.DictionaryPublishedContent.<.ctor>b__37(String val)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache.DictionaryPublishedContent.ValidateAndSetProperty(IDictionary`2 valueDictionary, Action`1 setProperty, String[] potentialKeys)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache.DictionaryPublishedContent..ctor(IDictionary`2 valueDictionary, Func`2 getParent, Func`3 getChildren, Func`3 getProperty, XPathNavigator nav, Boolean fromExamine)
at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache.CreateFromCacheValues(CacheValues cacheValues)
at Umbraco.Web.PublishedCache.ContextualPublishedCache`1.GetById(Boolean preview, Int32 contentId)
at MYDLL.PropertyConverters.MultipleMediaPickerPropertyConverter.ConvertSourceToObject(PublishedPropertyType propertyType, Object source, Boolean preview)
at Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedProperty.get_Value()
at MYDLL.Controllers.SharedSurfaceController.FavIcon()
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<>c__DisplayClass2b.<BeginInvokeAction>b__1c()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.<>c__DisplayClass4.<Wrap>b__3()
at System.Web.Mvc.HttpHandlerUtil.ServerExecuteHttpHandlerWrapper.Wrap[TResult](Func`1 func)
at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride)
Make some changes in the file (PublishedMediaCache.cs) Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache
and find method ParseDateTimeValue, then change it like below
private DateTime ParseDateTimeValue(string val)
{
if (LoadedFromExamine)
{
try
{
//we might need to parse the date time using Lucene converters
return DateTools.StringToDate(val);
}
catch (FormatException)
{
//swallow exception, its not formatted correctly so revert to just trying to parse
}
}
try
{
var datetimeNow = DateTime.Now;
DateTime.TryParse(val, out datetimeNow);
return datetimeNow;
}
catch
{
return DateTime.Now;
}
}
Build the project and go to Umbraco.Web/bin/Release (or Debug) folder and copy umbraco.dll
So do I. Having more and more arabic sites this is really painfull to maintain. Using v7.14
System.FormatException: String was not recognized as a valid DateTime. at System.DateTimeParse.Parse(String s, DateTimeFormatInfo dtfi, DateTimeStyles styles) at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache.DictionaryPublishedContent.ParseDateTimeValue(String val) at Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache.DictionaryPublishedContent.<>c__DisplayClass1_0.<.ctor>b__15(String val)...
FormatException after upgrade from 7.5.7 to 7.6.1
Hi, Since few days - after upgrading Umbraco from 7.5.7 to 7.6.1 I am facing issue with FormatException (String was not recognized as a valid DateTime). This happens randomly - from time to time and only for Arabic localization (ar-SA culture). Please find below tracelog. I would appriciate some help with that because it looks like something is wrong with parsing create or update date of IPublishedContent right after it was received from umbraco cache. Thanks in advance
Hi, I have a same problem. Below my steps to fix
Go to GitHub and choose right version of Umbraco that you are using https://github.com/umbraco/Umbraco-CMS/releases, then clone that source code to local.
Make some changes in the file (PublishedMediaCache.cs) Umbraco.Web.PublishedCache.XmlPublishedCache.PublishedMediaCache and find method ParseDateTimeValue, then change it like below
private DateTime ParseDateTimeValue(string val) { if (LoadedFromExamine) { try { //we might need to parse the date time using Lucene converters return DateTools.StringToDate(val); } catch (FormatException) { //swallow exception, its not formatted correctly so revert to just trying to parse } } try { var datetimeNow = DateTime.Now; DateTime.TryParse(val, out datetimeNow); return datetimeNow; } catch { return DateTime.Now; } }
Build the project and go to Umbraco.Web/bin/Release (or Debug) folder and copy umbraco.dll
Having the same issue, did you get this resolved Adam?
So do I. Having more and more arabic sites this is really painfull to maintain. Using v7.14
/Asembli
is working on a reply...