troubleshooting Question

Workflow, passing an object to a workflow

Avatar of jackwebb22002
jackwebb22002Flag for United States of America asked on
.NET ProgrammingMiscellaneous
10 Comments1 Solution456 ViewsLast Modified:
I'm learning Workflow using the book ProWF by Bruce Bukovics, and have a question.

I see examples of passing value type parameters from the host to the workflow, but when I

try to pass a class type parameter, I get:
"Event \"OccasionReceived\" on interface type \"SharedWorkflows.IOrderServices\" for

instance id \"99a5a2a5-155c-4e34-a793-1fbf792f7727\" cannot be delivered."

Relevant Snippets:

IOrderServices.cs

    /// <summary>
    /// Define the contract for placing an order
    /// </summary>
    [ExternalDataExchange]
    public interface IOrderServices
      {
        /// <summary>
        /// Occasion
        /// </summary>
        event EventHandler<OccasionReceivedEventArgs> OccasionReceived;

        /// <summary>
        /// Send a message to the host application
        /// </summary>
        /// <param name="message"></param>
        void OnSendMessage(String message);

        /// <summary>
        /// Send a request to host to get Occasion
        /// </summary>
        /// <param name="message"></param>
        void OnSendRequestOccasion(String message);
    }

OrderServics.cs


using System;
using System.Workflow.Activities;
using System.Workflow.Runtime;

namespace SharedWorkflows
{
    /// <summary>
    /// A local service that provides events used to create an Order
    /// </summary>
    public class OrderService : IOrderServices
      {
        #region IOrderServices
        public event EventHandler<OccasionReceivedEventArgs> OccasionReceived;

        /// <summary>
        /// Send a message from a workflow to the host application
        /// </summary>
        /// <param name="message"></param>
        public void OnSendMessage(String message)
        {
            if (MessageReceived != null)
            {
                MessageReceivedEventArgs args = new MessageReceivedEventArgs

(WorkflowEnvironment.WorkflowInstanceId, message);
                MessageReceived(this, args);
            }
        }

        /// <summary>
        /// Send a request from workflow to host to get Occasion
        /// </summary>
        /// <param name="message"></param>
        public void OnSendRequestOccasion(String message)
        {
            if (RequestOccasion != null)
            {
                MessageReceivedEventArgs args = new MessageReceivedEventArgs

(WorkflowEnvironment.WorkflowInstanceId, message);
                RequestOccasion(this, args);
            }
        }
        #endregion

        #region Members used by the host application
        public event EventHandler<MessageReceivedEventArgs> MessageReceived;
        public event EventHandler<MessageReceivedEventArgs> RequestOccasion;

        public void OnOccasionReceived(OccasionReceivedEventArgs args)
        {
            if (OccasionReceived != null)
            {
                OccasionReceived(null, args);
            }
        }
        #endregion
      }
}



OccasionReceivedEventArgs.cs :

using System;
using System.Workflow.Activities;
using pos_N3;

namespace SharedWorkflows
{
    /// <summary>
    /// Passes an Occasion from the UI to the workflow via the local service
    /// </summary>
    [Serializable]
    public class OccasionReceivedEventArgs : ExternalDataEventArgs
    {
        public Occasion Occasion { get; set; }
        public OccasionReceivedEventArgs(Guid instanceId, Occasion occasion)
            : base(instanceId)
        {
            Occasion = occasion;
        }
    }
}

UI Occasion selected by the click of a button.  Button's Tag property contains actual

Occasion row from Database:


        private void btnOccasion_Click(object sender, EventArgs e)
        {
            Button x = (Button)sender;
            Occasion y = (Occasion)x.Tag;
            Standards.at_Occasion = pos_N3.Occasion.Clone(y);
            if (Standards.at_Occasion != null)
            {
                OccasionReceivedEventArgs args = new OccasionReceivedEventArgs(_instanceId,

Standards.at_Occasion);
                args.WaitForIdle = true;
                try
                {
                    _orderService.OnOccasionReceived(args);
                }
                catch (Exception exception)
                {
                    String jjwMsg = exception.Message;
                    MessageBox.Show(exception.Message, "Sending Occasion Exception",

MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }


Error occurs just above where I tried the _orderService.OnOccasionReceived(args);

Has anyone passed a class parameter to a workflow?  If so, what did I not get from the

book?  Or was I asleep during that chapter?

Thanks ever so much,

JJW
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 10 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 10 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros