在爲重新託管的工作流設計器編寫自定義活動時,如果我沒有必要參數,它會給我一個錯誤,即必需參數需要一個值,所以我使用如下所示的null或「ALL」。它不接受null或「ALL」或任何其他的默認參數。請注意我需要的參數是字符串類型。運行工作流時工作流基礎中自定義活動的必需參數的默認值
[RequiredArgument]
[DefaultValue(null)]
[Description(@"The status of the job to perform")]
public InArgument<string> JobStatus { get; set; }
[RequiredArgument]
[DefaultValue("All")]
[Description(@"The status of the job to perform")]
public InArgument<string> JobStatus { get; set; }
錯誤消息:
Workflow Console: Starting Workflow...
Could not start workflow.
Message: Failed to start workflow DynamicActivity.
Exception message: The following errors were encountered while processing the workflow tree: 'DynamicActivity': The private implementation of activity '1: DynamicActivity' has the following validation error: Value for a required activity argument 'JobStatus' was not supplied.
Stack trace: at System.Activities.Validation.ActivityValidationServices.ThrowIfViolationsExist(IList`1 validationErrors) at System.Activities.Hosting.WorkflowInstance.ValidateWorkflow(WorkflowInstanceExtensionManager extensionManager) at System.Activities.Hosting.WorkflowInstance.RegisterExtensionManager(WorkflowInstanceExtensionManager extensionManager) at System.Activities.WorkflowApplication.EnsureInitialized() at System.Activities.WorkflowApplication.Enqueue(InstanceOperation operation, Boolean push) at System.Activities.WorkflowApplication.WaitForTurn(InstanceOperation operation, TimeSpan timeout) at System.Activities.WorkflowApplication.InternalRun(TimeSpan timeout, Boolean isUserRun) at System.Activities.WorkflowApplication.Run()
感謝您的幫助
所以你說,如果你不使用'DefaultValue'你得到一個編譯錯誤? –
不,我沒有收到編譯錯誤。當我運行程序時,工作流程不會運行。我會在一分鐘後發佈錯誤消息。 – user1298925
爲什麼在沒有首先驗證它的情況下執行工作流?那麼工作流設計師是不是會告訴你這些InArguments需要一個值? – Joao