自定义SharePoint工作流操作始终返回错误

时间:2013-07-15 15:23:16

标签: sharepoint sharepoint-2010 sharepoint-workflow

我正在开发一个自定义工作流操作,以便在SharePoint Designer中使用,该操作将从列表中返回连接的字符串。它实际上在动作内部工作正常,但总是返回错误。

  

测试工作流程中发生错误

在ULS日志中有一个空指针错误,除了我看不到的地方。

System.NullReferenceException: Object reference not set to an instance of an object.
     at Microsoft.SharePoint.WorkflowActions.SPUserCodeWorkflowActivity.ExecuteUserCode()
     at Microsoft.SharePoint.WorkflowActions.SPUserCodeWorkflowActivity.System.Workflow.ComponentModel.IActivityEventListener<System.Workflow.ComponentModel.ActivityExecutionStatusChangedEventArgs>.OnEvent(Object sender, ActivityExecutionStatusChangedEventArgs e)
     at System.Workflow.ComponentModel.ActivityExecutorDelegateInfo`1.ActivityExecutorDelegateOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
     at System.Workflow.Runtime.Scheduler.Run()

我很难理解为什么它在方法结束时返回错误。这里调用的方法

public Hashtable ListColumnToString(SPUserCodeWorkflowContext context, string ListName, string ColumnName, string Delimiter)
{
    Hashtable results = new Hashtable();

    try
    {
        using (SPSite site = new SPSite(context.CurrentWebUrl))
        {
            using (SPWeb web = site.OpenWeb())
            {
                SPList list = web.Lists[new Guid(ListName)];
                string output = string.Empty;

                foreach (SPItem item in list.Items)
                {
                    output += item[ColumnName].ToString() + Delimiter;
                }

                results["OutputString"] = output;

                SPWorkflow.CreateHistoryEvent(web,
                    context.WorkflowInstanceId,
                    0,
                    web.CurrentUser,
                    TimeSpan.Zero,
                    "Information",
                    output,
                    string.Empty);
            }
        }
    }
    catch (Exception ex)
    {
        results["OutputString"] = string.Empty;
    }

    return results;
}

工作流将使用我期望的正确记录输出值,并且在日志命令时,工作流操作已完成代码块,但工作流仍然在此步骤报告错误

enter image description here

我正在SharePoint Designer 2010中创建工作流,它只有一步,一个具有此自定义操作。如果我添加了其他操作,则由于此错误而永远无法访问。

enter image description here

如何让此工作流操作返回成功?

Elements.xml - 如果相关,这里是操作XML

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <WorkflowActions>
    <Action Name="List Column to String"
            SandboxedFunction="true"
            Assembly="$SharePoint.Project.AssemblyFullName$"
            ClassName="ListColumnToStringActivity"
            FunctionName="ListColumnToString"
            AppliesTo="all"
            Category="My Custom">
      <RuleDesigner Sentence="From %1 list, %2 column. Save to string %3 with %4 delimiter">
        <FieldBind Field="ListName" Id="1" Text="List name" DesignerType="ListNames" />
        <FieldBind Field="ColumnName" Id="2" Text="Column name" DesignerType="Text" />
        <FieldBind Field="OutputString" Id="3" Text="Output string" DesignerType="ParameterNames" />
        <FieldBind Field="Delimiter" Id="4" Text="Delimiter for columns" DesignerType="Text" />
      </RuleDesigner>
      <Parameters>
        <Parameter Name="__Context"
                   Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions"
                   Direction="In"
                   DesignerType="Hide" />
        <Parameter Name="ListName"
                   Type="System.String, mscorelib"
                   Direction="In"
                   DesignerType="ListNames"
                   Description="Name of list" />
        <Parameter Name="ColumnName"
                   Type="System.String, mscorelib"
                   Direction="In"
                   DesignerType="TextBox"
                   Description="Name of column" />
        <Parameter Name="OutputString"
                   Type="System.String, mscorelib"
                   Direction="Out"
                   DesignerType="ParameterNames"
                   Description="Delimited string returned" />
        <Parameter Name="Delimiter"
                   Type="System.String, mscorelib"
                   Direction="In"
                   DesignerType="TextBox"
                   Description="Delimiter" />
      </Parameters>
    </Action>
  </WorkflowActions>
</Elements>

更新

经过大量的研究,我在执行工作流程时在ULS日志中发现了三个条目。我不知道如何解决这些问题,但听起来我在某个地方缺少整个配置文件。

Solution Deployment : Looking for 'ReceiverAssembly' attribute in manifest root node for solution 'SharePoint.ListColumnToString.wsp'.   
Solution Deployment : Looking for 'ReceiverClass' attribute in manifest root node for solution 'SharePoint.ListColumnToString.wsp'.
Solution Deployment : Missing one or more of the following attributes from the root node in solution SharePoint.ListColumnToString.wsp: assembly '', type ''.   

0 个答案:

没有答案