Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to create a simple workflow containing a while in which you can find : createtaskwithcontenttypes while Ontaskchanged completetask

When I try to launch the workflow by adding a new item to my associate list, I find myself with a "Error occured". So I tried to debug a little and found out that the error was on the ontaskchanged event receiver. But the only thing it does is leaving the workflow. I have no error message or whatever.

So I've looked upon the internet, and found out some similar problem. But I guess I didn't find mine, or I didn't understand what it was about !

Here is my create task method :

private void createTaskWithContentType1_MethodInvoking(object sender, EventArgs e)
{
    TaskProperties = new SPWorkflowTaskProperties();
    TaskId = Guid.NewGuid();
    TaskProperties.Title = Title;
    TaskProperties.Description = DescriptionName;
    TaskProperties.DueDate = DueDate;
    TaskProperties.AssignedTo = this.Approver;
    TaskProperties.PercentComplete = 0;
    TaskProperties.StartDate = DateTime.Today;
}

Here is my while code condition :

private void WaitResponse_Invoke(object sender, ConditionalEventArgs e)
{
    e.Result = !isFinished;
}

Here is the invoked method of my ontaskchanged event receiver (basically does nothing) :

private void WaitApproval_Invoked(object sender, ExternalDataEventArgs e)
{           
}

Here are the after and before propertie : public static DependencyProperty WaitApproval_AfterPropertiesProperty =

DependencyProperty.Register("WaitApproval_AfterProperties", typeof(Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties), typeof(ActivityLibrary.EtapeOuiNon));

    [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
    [BrowsableAttribute(true)]
    [CategoryAttribute("Misc")]
    public Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties WaitApproval_AfterProperties
    {
        get
        {
            return ((Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties)(base.GetValue(ActivityLibrary.EtapeOuiNon.WaitApproval_AfterPropertiesProperty)));
        }
        set
        {
            base.SetValue(ActivityLibrary.EtapeOuiNon.WaitApproval_AfterPropertiesProperty, value);
        }
    }

    public static DependencyProperty WaitApproval_BeforePropertiesProperty = DependencyProperty.Register("WaitApproval_BeforeProperties", typeof(Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties), typeof(ActivityLibrary.EtapeOuiNon));

    [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
    [BrowsableAttribute(true)]
    [CategoryAttribute("Misc")]
    public Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties  WaitApproval_BeforeProperties
    {
        get
        {
            return ((Microsoft.SharePoint.Workflow.SPWorkflowTaskProperties)(base.GetValue(ActivityLibrary.EtapeOuiNon.WaitApproval_BeforePropertiesProperty)));
        }
        set
        {
            base.SetValue(ActivityLibrary.EtapeOuiNon.WaitApproval_BeforePropertiesProperty, value);
        }
    }

For information the correlation token is the same everywhere. Also all of this part of my workflow are in a separate activity.

So if someone has an idea of what it could be ! Thanks a lot !

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I've found the problem ! When the ontaskchanged event is accessed, the workflow is trying to serialize itself, so that it can be stock while waiting for the event to be triggered !

The problem is that in my workflow i was using personalize object which were not serialazible as public variable :

public sealed partial class Workflow1 : SequentialWorkflowActivity
{
    public Workflow1()
    {
        InitializeComponent();
    }
    public List<DefEtape> ListeEtapes = new List<DefEtape>();
    public DefEtape etapeEnCours = new DefEtape();

To overcome this proble I've just added : [Serializable] to my classes so that it became :

namespace CSPIMMOHelper
{
    [Serializable]
    public class DefEtape
    {

I hope this will help some people

share|improve this answer
    
Hi Thomas, if you have answered your own question - don't forget to mark it as answered :-) –  spStacker Jul 27 '12 at 20:20
    
Yep, just couldn't do it before ;) –  Thoma Bigueres Jul 30 '12 at 9:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.