The PageFlowProvider type is injecting in Controller constructor

Topics: Web Client Software Factory, User Forum
Feb 21, 2007 at 5:32 PM
Hi,

I am creating simple PageFlow for my application. I am unable to inject the PageFlowProvider type. Here is the sample code written in my controller.

public class AuthenticateController
{
IAuthenticateServiceAgent _authSerAgent;

InjectionConstructor
public AuthenticateController
(ServiceDependencyAttribute(Required = false) IAuthenticateServiceAgent authSerAgent
)
{
_authSerAgent = authSerAgent;
}

public AuthenticateController
(
ProviderDependency(typeof (PageFlowDirectory)) IPageFlowProvider pageFlowProvider
)
{
_pageFlowProvider = pageFlowProvider;
}


public string NavigateToAuthentication()
{
return _authSerAgent.TestMethod();
}

private IPageFlow _authenticatePageFlow;

private IPageFlowProvider _pageFlowProvider;

protected IPageFlow AuthenticatePageFlow
{
get
{
if (_authenticatePageFlow == null)
{
_authenticatePageFlow = _pageFlowProvider.GetPageFlow(typeof(PageFlow1));
}
return _authenticatePageFlow;
}
}


public virtual void StartAuthenticatePageFlow()
{
AuthenticatePageFlow.Start();
AuthenticatePageFlow.RedirectToCurrentPage();
}
}

The web.config is:

<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"/>
</sectionGroup>

<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=loaclhost;" />
<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>
</pageFlow>


Also, can anyhelp me what are the items I need to write in the Web.Config file? I couldn't find any help on this.
I am calling my controller class from OnViewinitialized() method. When the controller called the _pageFlowProvider is always returning null, because this var is not yet initialized. What is the alternative way to do this.

Any other info if you need Please let me know.. Please help me...

Cheers,
Ramesh
Feb 21, 2007 at 5:35 PM
Actually Title is little bit of wrong, It's not INJECTING the PageFlowProvider type.
Feb 21, 2007 at 5:50 PM
I've just looked at this very quickly, but at first glance I think it is because you have two constructors;

InjectionConstructor
public AuthenticateController(ServiceDependency AuthenticateServiceAgent authSerAgent
)
{...}

public AuthenticateController(ProviderDependency(typeof (PageFlowDirectory)) IPageFlowProvider pageFlowProvider)
{...}

Only the first of these will be used by ObjectBuilder due to the InjectionConstructor attribute. You should therefore combine them into one;

InjectionConstructor
public AuthenticateController(ServiceDependency AuthenticateServiceAgent authSerAgent, ProviderDependency(typeof (PageFlowDirectory)) IPageFlowProvider pageFlowProvider)
{ ... }

I think that would sort it - shout up if not and I'll have another look when I get a chance!

Hope that helps

Simon
http://www.dotnetblogs.co.uk/
Feb 22, 2007 at 9:03 AM
The above way also I did, but Ambiguous Error is displaying. The error is: AmbiguousMatchException: Ambiguous match found.
Also, In web.Config file what are the sections I have to include? If possible try to give some link :-)

No luck,
Cheers,
Ramesh T
Feb 24, 2007 at 12:01 PM
I added the two parameters in a single controller CtoR. Here is the code;


InjectionConstructor
public AuthenticationController
(ServiceDependency(Required = false) IAuthenticateServiceAgent authSerAgent
, ProviderDependency(typeof(PageFlowDirectory)) IPageFlowProvider pageFlowProvider
)
{
_authSerAgent = authSerAgent;
_pageFlowProvider = pageFlowProvider;

}

Web.Config
------------

<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>

<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="WorkFlowPersistanceStore"/>
<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="PageFlowQuickstart.Infrastructure.PageFlow.SimplePageFlowInstanceStoreProvider, PageFlowQuickstart.Infrastructure.PageFlow" connectionString=""/>
<pageFlowInstanceCorrelationTokenProvider providerType="PageFlowQuickstart.Infrastructure.PageFlow.NullCorrelationTokenProvider, PageFlowQuickstart.Infrastructure.PageFlow"/>
</pageFlow>

Not the application moved a little-bit. Now i am getting another error:
"Format of the initialization string does not conform to specification starting at index 0"
While calling StartRuntim() in Microsoft.Practices.PageFlow.WorkflowFoundation.WorkflowFoundationPageFlowFactory class, the above error is displays.

Can anyone help me on this..

Feb 26, 2007 at 12:48 PM
I resolved this issue, if anyone wants help on this let me know.

Cheers,
Ramesh
May 4, 2007 at 3:56 PM
Hi,

I'm having the same problem. Could you share your solution?
( And please do allways share your solutions. )

Thanks,
Eli
Jul 9, 2007 at 4:07 PM
Edited Jul 10, 2007 at 3:14 AM
I have run into every problem mentioned. I have the 3 entries in the config file, the property with the ProviderDependency(typeof (PageFlowDirectory)) IPageFlowProvider getter setter, the IPageFlow that returns my object etc. . . But it appears that my page flow provider is never injected. It is a null reference when I have _pageFlow = _pageflowProvider.GetPageFlow(typeof(pageFlow)), the pageflowProvider is always null. Why? This is supposed to be injected by the Object Builder but it is not. I have fooled with every web.config under the sun from every example I can find. But to no avail. Does anyone know where there is a sample of using a Page Flow with WCSF? I have found the ones with Component Web Application Block that create a workflow runtime via code, but I want to use the WCSF and injection. I can find no documentation anywhere, the documentation included stops way too short of actual help. Thanks ahead of time.
Sep 16, 2007 at 12:28 PM


Can anybobody please resolve the Issue of "Format of the initialization string does not conform to specification starting at index 0"
This happens when ever my project runs through the given code
protected IPageFlow CustomerRegPageFlow
{
get
{
if (_CustomerRegPageFlow == null)
{
_CustomerRegPageFlow = _pageFlowProvider.GetPageFlow(typeof(RegistrationPageFlow));
}
return _CustomerRegPageFlow;
}
}