SharePoint工作流开发点滴(4) - 工作流中的自定义类与内部错误

时间:2011-10-02 博客园 笑煞天

老葡京网站娱乐 www.sdguanhua.com 最近在开发SharePoint工作流总是发生一个错误 :工作流开始之后便显示"已完成"或者开始之后报错" 内部错误".

查看当时的日志,发现下面的段落:

  02/06/2007 10:31:03.92     w3wp.exe (0x0758)
  0x0F3C    Windows SharePoint Services     Workflow Infrastructure     72eo    Unexpected
   DehydrateInstance: System.Runtime.Serialization.SerializationException: 在分析完成之前就遇到 流结尾。
  在 System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
   在 System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
  在 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
  在 System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
  在 System.Workflow.ComponentModel.Activity.Load(Stream stream, Activity outerActivity, IFormatter formatter)...    
  02/06/2007 10:31:03.92*     w3wp.exe (0x0758)
  0x0F3C    Windows SharePoint Services     Workflow Infrastructure     72eo    Unexpected    ...
  在 System.Workflow.ComponentModel.Activity.Load(Stream stream, Activity outerActivity)
   在 System.Workflow.Runtime.Hosting.WorkflowPersistenceService.RestoreFromDefaultSerializedForm (Byte[] activityBytes, Activity outerActivity)
  在 Microsoft.SharePoint.Workflow.SPWinOePersistenceService.LoadWorkflowInstanceState(Guid instanceId)
  在 System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance)
  在 System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context, WorkflowInstance workflowInstance) 在 System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId)
  在 Microsoft.SharePoint.Workflow.SPWinOeHostServices.DehydrateInstance(SPWorkflowInstance wo...     
  02/06/2007 10:31:03.92*    w3wp.exe (0x0758)
  0x0F3C     Windows SharePoint Services     Workflow Infrastructure     72eo    Unexpected     ...rkflow)
  02/06/2007 10:31:03.93     w3wp.exe (0x0758)
  0x0F3C     Windows SharePoint Services     Workflow Infrastructure     88xr    Unexpected     WinWF Internal Error, terminating workflow Id# 472dae03-5465-4f04-876f- d4cc4caa902a

看里边最长的一段中文描述:"在分析完成之前就遇到流结尾",如果是SharePoint英文版,这段错误信息 应该是"End of Stream encountered before parsing was completed".

也就是说Workflow Runtime根本就没有完整的分析完整个流程.

再看这句中文之前的英文:"DehydrateInstance: System.Runtime.Serialization.SerializationException".

原来工作流是在钝化实例的时候发生了序列化异常.

回想一下工作流的持久性,Workflow Runtime会把空闲的工作流数据序列化为XML形式,然后把工作流实 例从内存中清除,等到需要的时候再将其反序列化加载到内存.

会不会是因为我在工作流项目中添加了自定义类,而这个类又不支持序列化,所以导致工作流序列化失 败?