NullReferenceException WCSF

Topics: Web Client Software Factory
Jul 2, 2007 at 12:23 AM
Hello, i'm trying to build my first wcsf with a pageflow. My idea was to build an application with an initial state that references my initial page that has a button to redirect to the next page/state. I followed the example in the wcsf source code (PageFlow example) and when I execute the application i get the following message:

Error de servidor en la aplicación '/DevelopmentWebsite'.
--------------------------------------------------------------------------------

Referencia a objeto no establecida como instancia de un objeto.
Descripción: Excepción no controlada al ejecutar la solicitud Web actual. Revise el seguimiento de la pila para obtener más información acerca del error y dónde se originó en el código.

Detalles de la excepción: System.NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.

Error de código fuente:

Se ha generado una excepción no controlada durante la ejecución de la solicitud Web actual. La información sobre el origen y la ubicación de la excepción pueden identificarse utilizando la excepción del seguimiento de la pila siguiente.

Seguimiento de la pila:


NullReferenceException: Referencia a objeto no establecida como instancia de un objeto.
Microsoft.Practices.PageFlow.PageFlowDirectory.BuildProvider() +183
Microsoft.Practices.PageFlow.PageFlowDirectory.get_Provider() +77

TargetInvocationException: Se produjo una excepción en el destino de la invocación.
System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +72
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +296
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +17
Microsoft.Practices.CompositeWeb.ProviderDependencyParameter.GetValue(IBuilderContext context) +144
Microsoft.Practices.ObjectBuilder.ConstructorPolicy.GetParameters(IBuilderContext context, Type type, String id, ConstructorInfo constructor) +143
Microsoft.Practices.ObjectBuilder.WCSFExtensions.CreationStrategy.InitializeObject(IBuilderContext context, Object existing, String id, ICreationPolicy policy) +175
Microsoft.Practices.ObjectBuilder.WCSFExtensions.CreationStrategy.BuildUpNewObject(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +480
Microsoft.Practices.ObjectBuilder.WCSFExtensions.CreationStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +66
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.WCSFExtensions.ReflectionStrategy`1.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +423
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.WCSFExtensions.ReflectionStrategy`1.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +423
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.WCSFExtensions.ReflectionStrategy`1.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +423
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +184
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.TypeMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id) +464
Microsoft.Practices.ObjectBuilder.CreationParameter.GetValue(IBuilderContext context) +48
Microsoft.Practices.ObjectBuilder.ConstructorPolicy.GetParameters(IBuilderContext context, Type type, String id, ConstructorInfo constructor) +143
Microsoft.Practices.ObjectBuilder.WCSFExtensions.CreationStrategy.InitializeObject(IBuilderContext context, Object existing, String id, ICreationPolicy policy) +175
Microsoft.Practices.ObjectBuilder.WCSFExtensions.CreationStrategy.BuildUpNewObject(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +480
Microsoft.Practices.ObjectBuilder.WCSFExtensions.CreationStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +66
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.WCSFExtensions.ReflectionStrategy`1.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +423
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.WCSFExtensions.ReflectionStrategy`1.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +423
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.WCSFExtensions.ReflectionStrategy`1.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +423
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +184
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.TypeMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id) +464
Microsoft.Practices.ObjectBuilder.CreationParameter.GetValue(IBuilderContext context) +48
Microsoft.Practices.ObjectBuilder.PropertySetterInfo.GetValue(IBuilderContext context, Type type, String id, PropertyInfo propInfo) +31
Microsoft.Practices.ObjectBuilder.PropertySetterStrategy.InjectProperties(IBuilderContext context, Object obj, String id) +315
Microsoft.Practices.ObjectBuilder.PropertySetterStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +44
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.WCSFExtensions.CreationStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +88
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.WCSFExtensions.ReflectionStrategy`1.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +423
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.WCSFExtensions.ReflectionStrategy`1.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +423
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.WCSFExtensions.ReflectionStrategy`1.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +423
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.SingletonStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +184
Microsoft.Practices.ObjectBuilder.BuilderStrategy.BuildUp(IBuilderContext context, Type typeToBuild, Object existing, String idToBuild) +63
Microsoft.Practices.ObjectBuilder.TypeMappingStrategy.BuildUp(IBuilderContext context, Type t, Object existing, String id) +464
Microsoft.Practices.ObjectBuilder.WCSFExtensions.WCSFBuilderBase`1.DoBuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) +114
Microsoft.Practices.ObjectBuilder.WCSFExtensions.WCSFBuilderBase`1.BuildUp(IReadWriteLocator locator, Type typeToBuild, String idToBuild, Object existing, PolicyList[] transientPolicies) +46
Microsoft.Practices.CompositeWeb.CompositionContainer.BuildItem(IBuilder`1 builder, IReadWriteLocator locator, Object item) +343
Microsoft.Practices.CompositeWeb.WebClientApplication.InnerPreRequestHandlerExecute(IHttpContext context) +134
Microsoft.Practices.CompositeWeb.WebClientApplication.Application_PreRequestHandlerExecute(Object sender, EventArgs e) +99
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

Please Help, Jay
Developer
Jul 2, 2007 at 3:40 PM
Hi,

Did you add the three configuration sections to your application configuration file? The error is raised in the BuildProvider method of the PageFlowDirectory class. That method reads the configuration in order to build the page flow provider.

Take a look to the topic Developing Web Client Applications | How to: Enable your solution for Page Flow of the WCSF Help.

Let me know if this helps,

Ezequiel Jadib
http://staff.southworks.net/blogs/ejadib
Jul 2, 2007 at 6:00 PM
Hello, i tried adding the first configuration section

<configSections>
<sectionGroup name="pageFlow">
<section name="pageFlowProvider" type="Microsoft.Practices.PageFlow.Configuration.PageFlowProviderSection, Microsoft.Practices.PageFlow"/>
<section name="hostingWorkflowRuntime" type="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<section name="pageFlowInstanceStoreProvider" type="Microsoft.Practices.PageFlow.Configuration.PageFlowInstanceStoreProviderSection, Microsoft.Practices.PageFlow"/>
<section name="pageFlowInstanceCorrelationTokenProvider" type="Microsoft.Practices.PageFlow.Configuration.PageFlowInstanceCorrelationTokenProviderSection, Microsoft.Practices.PageFlow"/>
</sectionGroup>
</configSections>

and I executed and got an exception like ArgumentNullException or something like that, but I never tried the last configuration part

<httpModules>
<add name="PageFlowModule" type="Microsoft.Practices.PageFlow.PageFlowHttpModule, Microsoft.Practices.PageFlow"/>
</httpModules>

I´m gonna try this and i´ll let you know what happens.

Thanks,

M.B
Jul 2, 2007 at 7:36 PM
Hi, i tried adding the three configuration parts into the xml. I've copied the xml for you to see:

<httpModules>
<add name="PageFlowPersona" type="Microsoft.Practices.PageFlow.PageFlowHttpModule, Microsoft.Practices.PageFlow"/>
<!--
<add name="WebClientAuthorizationModule" type="Microsoft.Practices.CompositeWeb.Authorization.WebClientAuthorizationModule, Microsoft.Practices.CompositeWeb"/>
<add name="ExceptionLoggerHttpModule" type="Microsoft.Practices.CompositeWeb.EnterpriseLibrary.ExceptionLogger, Microsoft.Practices.CompositeWeb.EnterpriseLibrary"/>
-->
</httpModules>

Mi PageFlow project is called PageFlowPersona


<pageFlow>
<pageFlowProvider providerType="Microsoft.Practices.PageFlow.WorkflowFoundation.WorkflowFoundationPageFlowProvider, Microsoft.Practices.PageFlow.WorkflowFoundation"/>
<hostingWorkflowRuntime Name="Hosting">
<Services>
<!--
<add type="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=WCSF_Quickstart;Data Source=.\SQLEXPRESS;" LoadIntervalSeconds="5" UnloadOnIdle="true"/>
-->
<add type="System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" useActiveTimers="true"/>
<add type="System.Workflow.Activities.ExternalDataExchangeService, System.Workflow.Activities, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</Services>
</hostingWorkflowRuntime>
<!--
<pageFlowInstanceStoreProvider providerType="Microsoft.Practices.PageFlow.Storage.EnterpriseLibrary.PageFlowInstanceCorrelationSqlProvider, Microsoft.Practices.PageFlow.Storage.EnterpriseLibrary" connectionString="PageFlowPersistanceStore"/>

<pageFlowInstanceCorrelationTokenProvider providerType="Microsoft.Practices.PageFlow.Storage.EnterpriseLibrary.CookiePageFlowCorrelationTokenProvider, Microsoft.Practices.PageFlow.Storage.EnterpriseLibrary" />
-->
</pageFlow>

I've commented those parts because i have no persistance implemented. I'ts simply a click to another page.

<sectionGroup name="pageFlow">
<section name="pageFlowProvider" type="Microsoft.Practices.PageFlow.Configuration.PageFlowProviderSection, Microsoft.Practices.PageFlow"/>
<section name="hostingWorkflowRuntime" type="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<!--
<section name="pageFlowInstanceStoreProvider" type="Microsoft.Practices.PageFlow.Configuration.PageFlowInstanceStoreProviderSection, Microsoft.Practices.PageFlow"/>

<section name="pageFlowInstanceCorrelationTokenProvider" type="Microsoft.Practices.PageFlow.Configuration.PageFlowInstanceCorrelationTokenProviderSection, Microsoft.Practices.PageFlow"/>
-->
</sectionGroup>

I've another web.config in Persona Folder, i've done these modifications on the web.config located in the root of the websites project.

The Persona Web.config:

<configuration>
<configSections>
<sectionGroup name="compositeWeb">
<section name="modules" type="Microsoft.Practices.CompositeWeb.Configuration.ModulesConfigurationSection, Microsoft.Practices.CompositeWeb"/>
<section name="authorization" type="Microsoft.Practices.CompositeWeb.Configuration.AuthorizationConfigurationSection, Microsoft.Practices.CompositeWeb"/>
</sectionGroup>
</configSections>
<compositeWeb>
<modules>
<module name="Persona" assemblyName="Persona" virtualPath="~/Persona">
<dependencies>
<dependency module="Shell" />
</dependencies>
</module>
</modules>
<authorization>
<!-- Add your own view-rule mappings here:
e.g.:
<rule Url="~/Persona/Default.aspx" Rule="AllowAccessPersonaDefaultView" />
-->
</authorization>
</compositeWeb>
<appSettings/>
<connectionStrings/>
<system.web />
</configuration>

It throws the following exception:

Error de servidor en la aplicación '/DevelopmentWebsite'.
--------------------------------------------------------------------------------
Se ha encontrado una coincidencia ambigua.
Descripción: Excepción no controlada al ejecutar la solicitud Web actual. Revise el seguimiento de la pila para obtener más información acerca del error y dónde se originó en el código.

Detalles de la excepción: System.Reflection.AmbiguousMatchException: Se ha encontrado una coincidencia ambigua.

Error de código fuente:

Se ha generado una excepción no controlada durante la ejecución de la solicitud Web actual. La información sobre el origen y la ubicación de la excepción pueden identificarse utilizando la excepción del seguimiento de la pila siguiente.

Seguimiento de la pila:


AmbiguousMatchException: Se ha encontrado una coincidencia ambigua.
System.DefaultBinder.BindToMethod(BindingFlags bindingAttr, MethodBase[] canidates, Object[]& args, ParameterModifier[] modifiers, CultureInfo cultureInfo, String[] names, Object& state) +2703244
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1036
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +114
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +23
Microsoft.Practices.PageFlow.PageFlowDirectory.BuildProvider() +297
Microsoft.Practices.PageFlow.PageFlowDirectory.get_Provider() +77
Microsoft.Practices.PageFlow.PageFlowHttpModule.ProcessRequest(HttpRequest request) +92
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

--------------------------------------------------------------------------------
Información de versión: Versión de Microsoft .NET Framework:2.0.50727.42; Versión ASP.NET:2.0.50727.42

Thanks, M.B
Developer
Jul 3, 2007 at 6:58 PM
Hi Martin,

The default provider of the Page Flow Application Block always requires an storage to persist the page flow’s instances between requests. Also the correlation provider is necessary for matching a page flow instance with a user. Take a look at the following topics of the WCSF Help:

  • Developing Web Client Applications | How to: Enable your solution for Page Flow.
  • Developing Web Client Applications | Migrating from the User Interface Process Application Block | Associating a Page Flow Instance with a User.
Because of that the configuration has to exist in the root web.config, so you have to uncomment what you commented.

BTW - If you don’t want to use the pageFlowInstanceStoreProvider and pageFlowInstanceCorrelationTokenProvider provided by the Microsoft.Practices.PageFlow.Storage.EnterpriseLibrary assembly, take a look to the implementations included in Infrastructure.PageFlow project of PageFlow quickstart (not the PageFlow with Shopping Cart quickstart). Those providers do all the stuff in memory, without using a database. Take a look at the following topic Inspecting the Software Factory Assets | QuickStarts | Page Flow, section Custom Providers of the WCSF Help.

Let me know if this helps,

Ezequiel Jadib
http://staff.southworks.net/blogs/ejadib
Jul 4, 2007 at 1:07 PM
Hi, thanks a lot, it really boosted up my project but i´ve got one last problem to solve. I´m gonna try to create the database to save the page flow instances. I tried running my aplication and I get the exception that i have no connection string defined. What script should i run to create the database? What information is stored in the db? Do I have to install SQL Server 2005? (Can i use the express edition?)

Thanks,

Martín