We have moved to GitHub Issues
Created by Bo Kingo Damgaard 10 Sep 2013, 08:58:58 Updated by Sebastiaan Janssen 30 Sep 2013, 13:16:46
I'm unable to store a date in a datepicker using the API, because Umbraco throws "Specified cast is not valid" even though the date is valid. This is an issues both when using the old and new API, but only since 6.1.4. It worked in 6.1.3, and it might be related to this issue http://issues.umbraco.org/issue/U4-2523
Code to reproduce: Install a simple website, and add a datepicker (alias date) to umbTextpage doctype. Then run this code somehow
ContentType DocType = (ContentType) ApplicationContext.Current.Services.ContentTypeService.GetContentType("umbTextpage"); var parent = ApplicationContext.Current.Services.ContentService.GetById(1051); Content NewDocument = new Content("test",parent,DocType); // Only use one of these lines. Either one will produce the same result when saving NewDocument.SetValue("date", "2013-03-09"); NewDocument.Properties["date"].Value = "2013-03-09"; ApplicationContext.Current.Services.ContentService.SaveAndPublish(NewDocument);
Now try this and note that you don't need to get the full doctype, just provide the alias
var cs = ApplicationContext.Current.Services.ContentService; var content = cs.CreateContent("Test", 1120, "umbTextPage"); content.SetValue("date", new DateTime(2013, 03, 09)); cs.Save(content);
I'm not sure what changed here though, it actually saves the date correctly even though it's throwing an exception now.
Oh yes, I forgot to mention that. It saves the data but throws an error
This seems to also be an issue when you package up content which has a datepicker property when you attempt to install the package the exception below is thrown. As you said this does not stop the content being created but it does stop any of the package actions running after.
[InvalidCastException: Specified cast is not valid.]
umbraco.editorControls.datepicker.DateData.ToXMl(XmlDocument d) +87
Umbraco.Core.Models.PropertyExtensions.ToXml(Property property, IDataTypeService dataTypeService) +356
Umbraco.Core.Models.PropertyExtensions.ToXml(Property property) +38
Umbraco.Core.Services.PackagingService.Export(IContentBase contentBase, String nodeName) +1271
Umbraco.Core.Services.PackagingService.Export(IContent content, Boolean deep) +119
Umbraco.Core.Models.ContentExtensions.ToXml(IContent content) +42
Umbraco.Web.Search.ExamineEvents.IndexConent(IContent sender) +22
1 items, Action1 action) +141
Umbraco.Web.Search.ExamineEvents.ContentServiceSaved(IContentService sender, SaveEventArgs
1 e) +55 Umbraco.Core.Events.TypedEventHandler2.Invoke(TSender sender, TEventArgs e) +0
2 eventHandler, TArgs args, TSender sender) +16 Umbraco.Core.Services.ContentService.Save(IEnumerable1 contents, Int32 userId, Boolean raiseEvents) +673
Umbraco.Core.Services.PackagingService.ImportContent(XElement element, Int32 parentId, Int32 userId) +198
umbraco.cms.businesslogic.packager.Installer.InstallBusinessLogic(Int32 packageId, String tempDir) +2289
umbraco.presentation.developer.packages.Installer.ProcessInstall(String currentStep) +208
umbraco.presentation.developer.packages.Installer.Page_Load(Object sender, EventArgs e) +425
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51
System.Web.UI.Control.OnLoad(EventArgs e) +92
umbraco.BasePages.BasePage.OnLoad(EventArgs e) +14
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929
Fix is in revision dc1a67bfa2b97de2494d8a58d2691090d9394ef1
Attached is a custom build of 6.1.5 plus only the fix for this issue. Make sure to backup your bin folder and then copy the files in this zip file into your bin folder, overwriting the existing ones.
If there's any issues with this make sure to report here but it should all work fine with this patch in place.
This is the error I'm receiving now:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
[NullReferenceException: Object reference not set to an instance of an object.]
Umbraco.Web.UmbracoModule.DisposeHttpContextItems(HttpContext http) +153
Make sure to turn off Browser Link in VS2013.. Sorry, it breaks Umbraco. :(
That was it Sebastiaan! Also, install of Standard Website MVC starter package was published, even with the error above so I think we're good! However, with BrowserLink on by default, how should I verify this for you all without starting all over again? Jon
I'm not sure what you mean? You can't use Browserlink with Umbraco 6.1.5 at the moment, we're looking to resolve this with Microsoft. We'll have a fix in place for 6.2.0, but for now you'll need to keep it turned off as advised on the 6.1.x download pages.
Ahhh! As I installed via Nuget I didn't realise this! The download page mentions "You can disable Browser Link temporarily to get through the installer." does this mean I can turn it back on now that everything seems to be installed or would I have to turn it off and on every time I install something new into the site?
Nope, they broke Umbraco completely with VS2013RC. It has to stay off. I'll update the release notes when I get a chance.
Sebastiaan, does this mean I can turn on my browserlink now if I update to v6.1.6?
Thanks chief! #h5yr!
@Jon it's just been released: http://umbra.co/17iKnrN
Assignee: Morten Christensen
Backwards Compatible: True
Affected versions: 6.1.4, 6.1.5
Due in version: 6.1.6