.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

DynamicActivity cannot reference a variable defined in parent workflow

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :JQuery

I have a custom activity that executes a workflow by creating a DynamicActivity instance that is then invoked using WorkflowInvoker.

Prior to invoking the DynamicActivity instance, I set up its Properties using a dictionary of Arguments I have populated using the DynamicArgumentDialog. One of the DynamicActivitiy properties is an out argument and I assign it an an expression that references a variable defined in the parent workflow. The intention of this is that the DynamicActivity workflow will attempt to write a result to the variable defined in the parent.

Here's the code that initialises the Proprerties collection (out arguments only):


 foreach (string argumentKey in Arguments.Keys)
    if (da.Properties.Contains(argumentKey))
     if (da.Properties[argumentKey].Type.GetGenericTypeDefinition().BaseType == typeof(OutArgument))
      da.Properties[argumentKey].Value = Arguments[argumentKey];      

   WorkflowInvoker invoker = new WorkflowInvoker(da);


where Arguments is Dictionary<string, Argument>, populated using DynamicArgumentDialog.

However, when Invoke is called I get the exception:

The following errors were encountered while processing the workflow tree:
'VisualBasicReference<Int32>': Compiler error(s) encountered

View Complete Post

More Related Resource Links

Composite Control which contains arbitrary content defined in .aspx of parent and thier ViewState


I want to write own control which can contain other. And I want to define content of the control in the .aspx file where the control is defined. I have written such control. But now I have issue with ViewState of inner controls of my control. The following samle illustrates the issue: I defined two asp:DropDownList ID="ddl1" and ID="ddl2" One of them is inside of my control and other is outside. When posback is occurred asp:DropDownList ID="ddl1 loses state and becomes empty. How to say ASP.net to store state of inner controls defined by this way?


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyControl.ascx.cs" Inherits="DynamicControls.Controls.MyControl" %>

<div class="box">
    <div class="Header-Left">
        <div class="Header-Right">
            My Control
    <div class="Content">
        <asp:PlaceHolder ID="contentPlace" runat="Server" />

BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its


why do i get

BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

with the code

 below ..thanks


<form id="form1" runat="server">
               <asp:Button ID="Button1" runat="server" Text="Run Access" />
In your code behind:

Workflow persistence with a non-serializable variable

I'm using Entity Framework and WF4. I want to be able to persist a workflow but one of my variables in the workflow is an EF ObjectContext. Is there a way to make the workflow persist-able and when it re-hydrates, has a fancy new ObjectContext instance?Blades Don't Need Reloading...

Passing a reference of the workflow to an activity

It there a way to pass in a reference of a workflow into an activity that the workflow is running (as an inargument)  in the Workflow designer?

Change Variable and Argument editor in workflow designer?

Is it possible, in Beta 2, to customize the behaviour of the editing grids use for entering data about a workflow's variables or arguments in the workflow designer?  Can I:- add my own custom column to the grid?- can I customize the variable type drop down editor? (e.g. have my own editor or otherwise filter the list of types)- can I change the "default" expression editor (and possibly remove it)?Thanks,Notre

Dynmic updation of Variable name in Workflow 4.0

Hi, I have created couple of variables & used them in workflow. Now suppose client changes the name of a variable then that has to be updated dynamically at all used places in that workflow. Any suggestions to achieve this...

Variable used before it is assigned value Null reference could

xamount is receiving this message on the last line.  The session is being set in the previous page.  Is there a way to resolve the message or should I just use a previous page postback  Dim subAmt As String = Session("MembType") Dim xamount As String Select Case subAmt Case "0" xamount = "40" Case "1" xamount = "5" Case "2" xamount = "20" Case "3" xamount = "2" End Select post_values.Add("x_amount", xamount)  

How to generate service reference for Workflow service from command line?

Is there a way to generate service reference for Workflow service from command line using just dll file (without metadata, without wsdl). I tried using svcutil but i didn't succeed. just error without any meaningful message. udione

How can i access to params and args defined in parent activity from custom NativeActivity


There is a scenario that the custom NativeActivity need to access to params or args defined in parent activity. What i have done as below

 protected override void Execute(NativeActivityContext context)


   WorkflowInstanceProxy proxy = context.GetExtension<WorkflowInstanceInfo>().GetProxy();

   Activity root = proxy.WorkflowDefinition;

   Activity rootChild = WorkflowInspectionServices.GetActivities(root).ElementAt(0);

   EditingContext ec = new EditingContext();

   ModelTreeManager mtm = new ModelTreeManager(ec);


   ModelItem modelItem = mtm.Root;

   ModelProperty c1 = modelItem.Properties["Variables"];

   ModelItemCollection c2 = c1.Collection;

   dynamic c3 = c2[0].GetCurrentValue();

   string value = c3.Get(context);


Apparently it is not possible to access to external params with local context so the error prompt "An activity can only access its own implementation variables."

My question is how to get it ? Is there another easy way to do so ?



be together be stro

how to trim a string value of a workflow variable using SharePoint designer.


I build a custom workflow using SP designer and have a need to trim a string value of a workflow variable. I tried using Calculation or Dynamic String builder but without success.

i store a user name type value into workflow variable called  check_name_var (string type). the logon name have this format  domainname\first_lastname 
how do i trim this value in check_name_var to only first_lastname.

Can anyone show me how or have suggest on how to accomplish this or is it possible to do this in SP designer?

Thanks for your help

How to pass a variable from parent to the hosted page in a frame. (Cross Posted due no reply from (V



I have - what might look like an obvious question - for me it is a headache.

Some background info:

In a WPF Window, I have placed a frame. A Ribbon button in the WPF window executes NavigationServices as you can see below. Mind there is no navigation History (back/Forward).

    Private Sub rTabToolsRgpSystemAdministrationRbtnPolicyEditor_Click(ByVal sender As ObjectByVal e As System.Windows.RoutedEventArgsHandles rTabToolsRgpSystemAdministrationRbtnPolicyEditor.Click
        InsertNavigationAction("Policy Editor")
        piFrame.NavigationService.Navigate(New System.Uri("piPolicyEditor.xaml"UriKind.Relative))

I am trying to pass a string variable (s

SSIS Parent/Child Package variable passing



I have having trouble getting my hands around how to retrieve variables from a parent package.  I read about the Environment variables and Configuration File at the parent package level and the Parent Package variable at the child level.

Here are my questions:

1.  Can you only store/retrieve 1 variable in a config file at a time?

2.  Does the child package have to define the variables and if so, do they have to be the same names as the parent package?

This seems so more more complex then the DTS2000 way of passing variables to and from packages.

Any help would be appreciated.

Thanks in advance,

Gordon Radley



Problem passing local variable for Approvers email in customised Approval workflow


I am building an Approval workflow using SPD and have used the Start an Approval Workflow task action.

The workflow works on a change register and looks up different list of approvers assigned to change items.

Using Local Variables, the look up assignment works fine.

My problem is that when I pass the Approvers variable to the email at the end of the workflow (the on Current Item with... part) it appears the variable in empty?

I have used the approach of adding a variable check in the content of the emails - as the workflow sends the emails anyway. The lookup works fine - it’s just the email at the end of the process that does not seem to be able to see the contents of the variables that are shown to be set earlier.

Sharepoint Workflow - Object Reference Not Set to an instance of an object



I create a Custom Sharepoint workflow using VS 2008. Let me go step by step:

1. I have an infopath form which is a requisition form.  I saved all my infppath source class and other custon class files in a Class library.

2. I built this class library and assigned a string key to it.

3. created a custom sequential workflow and added my class library dll to this workflow.

4. In my workflow I have a function where I am using :

                    using (SPSite currentSite = new SPSite(siteURL))
                        using (SPWeb currentWeb = currentSite.OpenWeb())

Quick Reference for state machine workflow in VS 2010

Any quick learning / crash course references on how to create state machine workflows in Visual Studio 2010?

Workflow designer rehosting and user defined types


I'm rehosting workflow designer, and I want to use my custom types as variables of the workflow. At first I couldn't get my types to be shown in the "Browse and Select a .Net Type" Window. I maneged to do that by loading assembly to AppDomain:


But now when I want to assign a property of a variable which is of type from my assembly I get the message: Compiler error(s) encountered processing expression "variable1.Attribute1" Type "BusinessObject1" is not defined

Dynamic Variable Names to Reference Actual set Variables


Here is an example of the concept I am used to in Coldfusion using EVALUATE and DEEVALUATE. Trying to accomplish something dynamic code side using ASP.NET C# .NET 4.0 and VS2010. The example should explain what I am trying to do... should be simple, reflaction, dynamic, eval of some kind? I thought I was close with Boolean.TryParse() but no luck even though logically it accepts a string why not convert to references variable?




bool test1 = true;

string dynboolname = "test" + 1;

if(dynboolname == true)




ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend