Sitefinity Error with Form Builder: Invalid Cast

by Gregg Crystal Nov 23, 2016

OK, chalk this one up to Sitefinity weirdness.

I didn't really 'solve' this bug so much as discover and come up with a work around. This is Sitefinity 8.2.5900:

Sitefinity Error with Form Builder: Invalid Cast

This was an issue with adding a Textbox to a form, and changing the Developer name to 'title'. Yep, that's it!

Just changing it to title caused the following error. I haven't tried this in the latest release but I will soon.

The only fix was to NOT name the field 'title'.

sf-blog-invalid-cast-02.png

Here's the error for anyone searching:

Server Error in '/' Application. 
Invalid cast from 'System.String' to 'Telerik.Sitefinity.Model.Lstring'.
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.InvalidCastException: Invalid cast from 'System.String' to 'Telerik.Sitefinity.Model.Lstring'.
Source Error:
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.
Stack Trace:
[InvalidCastException: Invalid cast from 'System.String' to 'Telerik.Sitefinity.Model.Lstring'.]
System.Convert.DefaultToType(IConvertible value, Type targetType, IFormatProvider provider) +12271702
System.String.System.IConvertible.ToType(Type type, IFormatProvider provider) +13
System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +12300467
System.Convert.ChangeType(Object value, Type conversionType) +32
Telerik.Sitefinity.Model.DataExtensions.SetValue(IDynamicFieldsContainer dataItem, String fieldName, Object value) +206
Telerik.Sitefinity.Modules.Forms.Web.FormsHelper.SaveFormEntryInternal(FormsManager manager, Guid formDescriptionId, IEnumerable`1 postedData, IDictionary`2 files, String userIpAddress, String formLanguage) +248
Telerik.Sitefinity.Modules.Forms.Web.<>c__DisplayClass1.b__0() +72
Telerik.Sitefinity.Data.ManagerExtensions.ExecuteAndCommitWithRetries(IManager manager, Action action, Int32 retryCount) +81
Telerik.Sitefinity.Modules.Forms.Web.FormsHelper.SaveFormsEntry(FormDescription formDescription, IEnumerable`1 postedData, IDictionary`2 files, String userIpAddress, Guid userId, String formLanguage) +174
Telerik.Sitefinity.Modules.Forms.Web.UI.FormsControl.SaveFormEntry(FormDescription description, IEnumerable`1 controls) +184
Telerik.Sitefinity.Modules.Forms.Web.UI.FormsControl.ProcessFormSaving(IEnumerable`1 validControlsSave) +131
Telerik.Sitefinity.Modules.Forms.Web.UI.FormsControl.ProcessFormSaving() +410
Telerik.Sitefinity.Modules.Forms.Web.UI.FormsControl.Submit_Click(Object sender, EventArgs e) +5
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9712662
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +204
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +12
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +15
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1639
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1586.0

  Ready to Supercharge Your Sitefinity Project