WWF的一些注意点[新手向]

时间:2022-02-26 20:31:00

1.
sqlserver2k 必须安装sp4补丁  (2005未测试)
否则使用SqlWorkflowPersistenceService 和SqlWorkflowTrackingService时会报错
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=182546&SiteID=1

2.
web.config 添加配置
<WorkflowRuntime Name="WorkflowServiceContainer">
    <CommonParameters>
      <add name="ConnectionString" value="Initial Catalog=SharedStore;Data Source=localhost;Integrated Security=SSPI;"/>
    </CommonParameters>
    <Services>
      <add type="System.Workflow.Runtime.Hosting.ManualWorkflowSchedulerService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral,

PublicKeyToken=31bf3856ad364e35"/>
      <add type="System.Workflow.Activities.ExternalDataExchangeService, System.Workflow.Activities, Version=3.0.00000.0, Culture=neutral,

PublicKeyToken=31bf3856ad364e35"/>
      <add type="System.Workflow.Runtime.Hosting.SharedConnectionWorkflowCommitWorkBatchService, System.Workflow.Runtime, Version=3.0.00000.0,

Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      <add type="System.Workflow.Runtime.Hosting.SqlWorkflowPersistenceService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral,

PublicKeyToken=31bf3856ad364e35" UnloadOnIdle="true"/>
      <add type="System.Workflow.Runtime.Tracking.SqlTrackingService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral,

PublicKeyToken=31bf3856ad364e35"/>
    </Services>
 </WorkflowRuntime>

即可以使用类似
SqlWorkflowPersistence persist = runtime.GetService<SqlWorkflowPersistence>();
的方法获取Service
要不然只能通过如此冗长的方式
SqlWorkflowPersistence persist = new SqlWorkflowPersistence (
connectionString,UnloadOnIdle,timeSpan,timeSpan);

添加
<add name="WorkflowHost" type="System.Workflow.Runtime.Hosting.WorkflowWebHostingModule, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
到 <httpModules></httpModules> 节

3.
当persistenceService 和trackingService使用在同一个数据库里时
必须添加SharedConnectionWorkflowCommitWorkBatchService

4.
新建工作流程Service时必须添加[ExternalDataExchange]Attribute
wwf与host通信时使用的class必须添加[Serializable],可供序列化

5.
asp.net环境下使用ManualWorkflowSchedulerService 默认单进程
使用scheduler.RunWorkflow(instanceId)驱动工作流程



一些资源
http://www.theserverside.net/tt/articles/showarticle.tss?id=ManageAppProcesses
http://www.theserverside.net/tt/articles/showarticle.tss?id=WorkforProcess
http://mtaulty.com/communityserver/blogs/mike_taultys_blog/default.aspx
http://forums.microsoft.com/msdn/showforum.aspx?forumid=122&siteid=1
http://biztalkgurus.com/windows-workflow-foundation.aspx
http://blogs.msdn.com/jamescon/

希望能够与大家多交流 学习  一个人学真的走了好多弯路  -_-