Unable to cast object of type 'System.Workflow.Activities.StateActivity' to type 'Microsoft.Practices.PageFlow.WorkflowFoundation.Activities.PageState'

Topics: Web Client Software Factory, User Forum
Apr 11, 2007 at 10:47 AM
Edited Apr 12, 2007 at 10:36 AM

I'm having an error which I can't understand the origin. Does it ring a bell to anyone?
I'm using an environment similar to reference implementation.

Thanks in advance,

Miguel Figueiredo

Server Error in '/DevelopmentWebsite' Application.

Unable to cast object of type 'System.Workflow.Activities.StateActivity' to type 'Microsoft.Practices.PageFlow.WorkflowFoundation.Activities.PageState'.
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: Unable to cast object of type 'System.Workflow.Activities.StateActivity' to type 'Microsoft.Practices.PageFlow.WorkflowFoundation.Activities.PageState'.

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: Unable to cast object of type 'System.Workflow.Activities.StateActivity' to type 'Microsoft.Practices.PageFlow.WorkflowFoundation.Activities.PageState'.
Microsoft.Practices.PageFlow.WorkflowFoundation.<>c_DisplayClass1.<GetActivityByUrl>b_0(Activity activity) +52
System.Collections.Generic.List`1.Find(Predicate`1 match) +60
Microsoft.Practices.PageFlow.WorkflowFoundation.WorkflowFoundationPageFlowDefinition.GetActivityByUrl(String rawUrl) +107
Microsoft.Practices.PageFlow.WorkflowFoundation.WorkflowFoundationPageFlowDefinition.ContainsUrl(String url) +30
Microsoft.Practices.PageFlow.<>c_DisplayClass1.<GetByUrl>b_0(IPageFlowDefinition definition) +31
System.Collections.Generic.List`1.Find(Predicate`1 match) +60
Microsoft.Practices.PageFlow.PageFlowDefinitionCatalog.GetByUrl(String rawUrl) +90
Microsoft.Practices.PageFlow.WorkflowFoundation.WorkflowFoundationPageFlowProvider.ProcessWithNoRunningInstance(String url) +53
Microsoft.Practices.PageFlow.WorkflowFoundation.WorkflowFoundationPageFlowProvider.ProcessRequest(String url) +230
Microsoft.Practices.PageFlow.PageFlowHttpModule.ProcessRequest(HttpRequest request) +115
Microsoft.Practices.PageFlow.PageFlowHttpModule.OnPostAcquireRequestState(Object sender, EventArgs e) +55
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

Version Information: Microsoft .NET Framework Version:2.0.50727.312; ASP.NET Version:2.0.50727.312
Apr 11, 2007 at 1:23 PM
Hi Miguel,

You are using a StateActivity instead of PageState activity.

If you don’t see the PageState activity in the toolbox, here are the steps to add it:

  • Right-click the Toolbox, and then click Choose Items.
  • In the Choose Toolbox Items dialog box, click the .NET Framework Components tab, and then click the Browse button to locate the assembly Microsoft.Practices.PageFlow.WorkflowFoundation.dll.
  • Select the assembly, and then click Open.
  • Select the PageState control check box and the TransitionListenerActivity control check box, and then click Open.
  • Click OK to close the Choose Toolbox Items dialog box.
Also you can read about PageFlow block in this topic: ms-help://MS.VSIPCC.v80/ms.practices.wcsf.2007dec/wcsf/html/02-140-Page_Flow_Application_Block.htm

Let me know if this helps,
Ezequiel Jadib
Apr 11, 2007 at 3:08 PM

Let me know if this helps,
Ezequiel Jadib

Hi... I had already done that, but your sugestion made me check, line by line, all class definitions and... in fact, there was a StateActivity by mistake.

Thanks for your response,