Try our conversational search powered by Generative AI!

Unable to cast object of type 'System.Guid' to type 'EPiServer.Data.Identity' (Xform)

Vote:
 

I'm having a problem on 1 of 2 load balanced web-servers running CMS6R2. Im trying to call insert an Xform into a page from a page property like so: 

EPiServer.XForms.XForm.CreateInstance(new Guid((string) CurrentPage["MyXFormProperty"]));

Stack trace:

[InvalidCastException: Unable to cast object of type 'System.Guid' to type 'EPiServer.Data.Identity'.]
   EPiServer.XForms.XForm.FromPropertyBag(PropertyBag properties) +589
   EPiServer.XForms.XForm.CreateInstance(Guid formId) +183
   MySite.Web.Templates.Units.MyXform.SetupForm() +268
   MySite.Web.Templates.Units.MyXform.Page_Init(Object sender, EventArgs e) +201
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25
   System.Web.UI.Control.InitRecursive(Control namingContainer) +133
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Control.InitRecursive(Control namingContainer) +421
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1970

    

When using Reflector on EPiServer.XForms.dll I find the last function called. From the stack trace the FolderId property cast seems to cause the issue.

    private static XForm FromPropertyBag(PropertyBag properties)
    {
      if (properties == null || properties.Count == 0)
        return (XForm) null;
      return new XForm()
      {
        StorageId = properties.Id,
        AllowAnonymousPost = (bool) properties["AllowAnonymousPost"],
        AllowMultiplePost = (bool) properties["AllowMultiplePost"],
        Changed = (DateTime) properties["Changed"],
        ChangedBy = (string) properties["ChangedBy"],
        Created = (DateTime) properties["Created"],
        CreatedBy = (string) properties["CreatedBy"],
        CustomUrl = (string) properties["CustomUrl"],
        DocumentData = (string) properties["DocumentData"],
        FolderId = (Identity) properties["FolderId"],
        FormName = (string) properties["FormName"],
        MailFrom = (string) properties["MailFrom"],
        MailSubject = (string) properties["MailSubject"],
        MailTo = (string) properties["MailTo"],
        PageGuidAfterPost = (Guid) properties["PageGuidAfterPost"],
        _responsePageId = (int) properties["PageAfterPost"]
      };
    }

    

 

Any ideas on what could be causing this issue? 

 

#76744
Nov 01, 2013 7:44
Vote:
 

Also, I'm getting a similar stack trace when trying to select the Xform via the page property:

[InvalidCastException: Unable to cast object of type 'System.Guid' to type 'EPiServer.Data.Identity'.]
   EPiServer.XForms.XForm.FromPropertyBag(PropertyBag properties) +589
   EPiServer.XForms.XForm.GetXformsList(IEnumerable formsPropsList) +168
   EPiServer.XForms.XForm.GetForms(String createdBy, Int32 skip, Int32 take, String orderBy, SortOrder sortOrder, Int32& count) +79
   EPiServer.UI.Edit.XFormSelect.GetPages(String formFolder, Boolean myFormsOnly, String formId, String sortExpression, Int32 maximumRows, Int32 startRowIndex, Int32& rowCount) +826

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +0
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +640
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +38
   System.Web.UI.WebControls.ObjectDataSourceView.InvokeMethod(ObjectDataSourceMethod method, Boolean disposeInstance, Object& instance) +1234
   System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1992
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +28
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +274
   EPiServer.UI.Edit.XFormSelect.LoadForms() +70
   EPiServer.UI.Edit.XFormSelect.OnLoad(EventArgs e) +989
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Control.LoadRecursive() +190
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064

    

#76746
Nov 01, 2013 8:20
Vote:
 

The issue turned out to be that the server giving the YSOD had the CMS6R1 version of EPiServer.Data.dll and EPiServer.Events.dll in the GAC (in addition of CMS6R2 version of these assemblies).

The fix was as simple as uninstalling these from the GAC (or simply uninstalling CMS6 R1 application files, as they are not in use anyway).

#76782
Nov 01, 2013 12:54
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.