1
votes

I am trying to create a custom workflow activity which gives me the list of recipients that I am storing in list. But once I deploy and start the workflow nothing is happening, not even log messages are coming. So i tried to debug the code but breakpoints are not set and I am getting the error "The Breakpoint will not currently be hit. No symbols have been loaded for this document." Can anyone please help me to deal with this issue.

Below are the steps I have followed in creating this activity. 1. created a workflow activity library. (please find my code file attached)

  1. added .dll to GAC
  2. updated web.config and WSS.actions files.
  3. Now I see the action in designer, so i have created a workflow using designer.
  4. strted the workflow manually on an item.

Here nothing is happening, not even an error. Please let me know if you need any further information.

Please find the code below.

using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Drawing;
using System.Linq;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;
using Microsoft.SharePoint;
using System.Diagnostics;
using Microsoft.SharePoint.Workflow;
using Microsoft.SharePoint.WorkflowActions;

namespace CustomWorkflowActivityLibrary
{
    public partial class CustomWorkflowActivity: SequenceActivity
    {
        SPList _list;
        private EventLog _log;
        SPFieldUserValueCollection objUserFieldValueCol;
        string semailsettingKeyword1;
        string semailsettingKeyword2;
        public CustomWorkflowActivity()
        {
            InitializeComponent();
        }

        public static DependencyProperty __ContextProperty = DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(CustomWorkflowActivity));
        [DescriptionAttribute("__Context")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]

        public WorkflowContext __Context
        {
            get { return ((WorkflowContext)(base.GetValue(CustomWorkflowActivity.__ContextProperty))); }
            set { base.SetValue(CustomWorkflowActivity.__ContextProperty, value); }
        }
        public static DependencyProperty ListIdProperty = DependencyProperty.Register("ListId", typeof(string), typeof(CustomWorkflowActivity));
        [DescriptionAttribute("ListId")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public string ListId
        {
            get { return ((string)(base.GetValue(CustomWorkflowActivity.ListIdProperty))); }
            set { base.SetValue(CustomWorkflowActivity.ListIdProperty, value); }
        }
        public static DependencyProperty ListItemProperty = DependencyProperty.Register("ListItem", typeof(int), typeof(CustomWorkflowActivity));
        [DescriptionAttribute("ListItem")]
        [BrowsableAttribute(true)]
        [DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]
        public int ListItem
        {
            get { return ((int)(base.GetValue(CustomWorkflowActivity.ListItemProperty))); }
            set { base.SetValue(CustomWorkflowActivity.ListItemProperty, value); }
        }
        private void codeActivity1_ExecuteCode(object sender, EventArgs e)
        {
        }
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            _log = new EventLog("Add Description");
            _log.Source = "Share Point Workflows";
            try
            {
                //Execute method as a elevated method                 
                SPSecurity.CodeToRunElevated elevatedExecuteMethod = new SPSecurity.CodeToRunElevated(ExecuteMethod);
                SPSecurity.RunWithElevatedPrivileges(elevatedExecuteMethod);
            }
            catch (Exception ex)
            {
                _log.WriteEntry("Error" + ex.Message.ToString(), EventLogEntryType.Error);
            }
            return ActivityExecutionStatus.Closed;
        }
        private void ExecuteMethod()
        {
            try
            {
                //retrieveing the Site object       
                SPSite _site = new SPSite(__Context.Site.Url);
                //retrieveing the Web object                 
                SPWeb _web = (SPWeb)(__Context.Web);
                //retrieveing the list object                 
                _list = _web.Lists[new Guid(this.ListId)];
                //retrieveing the list item object              
                SPListItem _listItem = _list.GetItemById(this.ListItem);
                _site.AllowUnsafeUpdates = true;
                _web.AllowUnsafeUpdates = true;
                string semailsubject = _listItem["E-Mail Subject"].ToString();
                string semailfrom = _listItem["emailfrom"].ToString();
                _log = new EventLog("get vendor info");
                _log.WriteEntry("semailsubject");
                _log.WriteEntry("semailfrom");

                /* _listItem.Update();
                 _list.Update();
                 _site.AllowUnsafeUpdates = false;
                 _web.AllowUnsafeUpdates = false;*/
                using (SPSite mysite = new SPSite("http://dlglobaltest.dl.com/Admin/IT/Application%20Development%20Group/LibraryEmailDistribution"))
                {
                    using (SPWeb myweb = mysite.OpenWeb())
                    {
                        SPList settingsList = myweb.Lists["EmailDistributionSettings"];
                        SPQuery oQuery = new SPQuery();
                        oQuery.Query = "<Where><Eq><FieldRef Name='Sender' /><Value Type='Text'>" + semailfrom + "</Value></Eq></Where>";
                        SPListItemCollection ColListItems = settingsList.GetItems(oQuery);
                        foreach (SPListItem oListItem in ColListItems)
                        {
                            semailsettingKeyword1 = oListItem["Keyword1"].ToString();
                            semailsettingKeyword2 = oListItem["Keyword2"].ToString();
                            //SPFieldUserValue objUserFieldValue = new SPFieldUserValue(myweb, oListItem["Recipients"].ToString());

                            if ((semailsubject.Contains(semailsettingKeyword1)) || (semailsubject.Contains(semailsettingKeyword2)))
                            {
                                objUserFieldValueCol = new SPFieldUserValueCollection(myweb, oListItem["Recipients"].ToString());
                                _log = new EventLog(objUserFieldValueCol.ToString());

                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            { }
        }
    }
}

Web.Config:

<authorizedType Assembly="CustomWorkflowActivityLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a95e146fc1062337" Namespace="CustomWorkflowActivityLibrary" TypeName="*" Authorized="True" />

WSS.Actions:

<Action Name="Get Recipients" 
            ClassName="CustomWorkflowActivityLibrary.CustomWorkflowActivity"
            Assembly="CustomWorkflowActivityLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a95e146fc1062337" 
            AppliesTo="all" Category="Custom">
            <RuleDesigner Sentence="Get Recipients for %1 "> 
           <FieldBind Field="ListId,ListItem" Text="this list" Id="1" DesignerType="ChooseListItem" />
        </RuleDesigner>   
         <Parameters> 
        <Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext" Direction="In" /> 
        <Parameter Name="ListId" Type="System.String, mscorlib" Direction="In" /> 
        <Parameter Name="ListItem" Type="System.Int32, mscorlib" Direction="In" /> 
            </Parameters> 

    </Action>

Thanks,

2
Did you perform an iisreset after deploying to the GAC?Kit Menke
Yes I did perform IISRESET. Still the same thing. I don't see anything once the workflow has been completed.user346514
You can start the workflow manually but nothing happens? Do you know if regular out of the box actions are working in your workflow? I might try creating a workflow without your custom action and make sure that works first.Kit Menke

2 Answers

0
votes

I am not sure if this will help but you could try changing the following line in your code from this:

SPSecurity.RunWithElevatedPrivileges(elevatedExecuteMethod); 

To this:

SPSecurity.RunWithElevatedPrivileges(delegate(){
    ExecuteMethod();
}); 
0
votes

Another shot-in-the-dark reply:

Try changing the class you're inheriting ( http://msdn.microsoft.com/en-us/library/ms173149(v=VS.80).aspx ) from SequenceActivity to Activity (SequenceActivity inherits from CompositeActivity, which itself inherits from Activity. See: http://msdn.microsoft.com/en-us/library/system.workflow.activities.sequenceactivity(v=VS.90).aspx )

If that doesn't work, try removing your constructor entirely. You should be able to use the base (Sequence)Activity constructor (since you're inheriting the class, not implementing it)

Hope that helps...