Joseph Michael Pesch
VP Programming

SharePoint Deploy Workflow Feature to Server Farm

by 11. January 2012 13:24

This post covers steps used to deploy the workflow feature to a SharePoint site (or sub-site as shown in this example URL: http://ServerNameHere/sites/SubSiteNameHere).  Attached is a sample SharePoint workflow feature that can configured to perform a daily refresh of an Excel file from a SharePoint site (i.e. refreshing the data connections to update data from external sources).

To setup the Visual Studio Solution, you will need to change the URL located in the three areas shown below:

  1. Project -> Site URL -> http://ServerNameHere/sites/SubSiteNameHere
  2. Web References -> ExcelWebService -> Web Reference URL -> http://ServerNameHere/sites/SubSiteNameHere/_vti_bin/excelservice.asmx
  3. Web References -> ListService -> Web Reference URL -> http://ServerNameHere/sites/SubSiteNameHere/_vti_bin/lists.asmx

When deploying the workflow feature on the server (either through Visual Studio right-click and “Deploy”; or, via Power Shell script shown below) I received the following error message:

Error occurred in deployment step 'Activate Features': Feature with Id '{GUID}' is not installed in this farm, and cannot be added to this scope.

Power Shell Deployment Script:

rem NOTE: Make sure the "Sharepoint 2010 Administration" service is NOT running.
rem We are using the execadmsvcjobs to execute rather than letting th Timer service run them.
rem ADDING...
cd "c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN"
stsadm -o addsolution -filename "C:\VSS\ExcelRefreshWorkflow\bin\Debug\ExcelRefreshWorkflow.wsp"
stsadm -o deploysolution -name "ExcelRefreshWorkflow.wsp" -immediate -allowgacdeployment -allowcaspolicies
stsadm -o execadmsvcjobs
stsadm -o activatefeature -name "ExcelRefreshWorkflow_Feature1" -url http://ServerNameHere/sites/SubSiteNameHere

NOTE: This feature is being deployed to “Scope = Site”, not Farm, Web or Web Application scope.


If you are running a single server instance of Sharepoint this should not happen (i.e. your deployment should be completed successfully). In the case of a Sharepoint server farm you will need to perform the following steps manually to complete the installation.

  1. From the “SharePoint 2010 Central Administration” site:
    • Navigate to: “System Settings” -> “Manage farm solutions”
    • Click on “excelrefreshworkflow.wsp”
    • Click on “Deploy Solution” and complete the deployment screen (schedule or run immediately).
    • Refresh the farm solutions screen until the solution management screen until the status column shows “Deployed” (note, the “Deployed To” column should show “Globally deployed.”).
    • NOTE: Make sure the “SharePoint 2010 Timer” service is running; otherwise, this step will not complete.
  2. Open the normal SharePoint site and from the top level site:
    • Navigate to: “Site Actions” -> “Site Settings” -> “Site Collection Administration” -> “Site collection features”
    • Click the “Activate” button associated with the “ExcelRefreshWorkflow” item in the list.
    • NOTE: Repeat this step on every sub-site that you want to use the workflow in.
  3. At this point the installation is complete. You can now navigate to the sub-site and configure the workflow on the appropriate Library and activate it on the appropriate documents in the library.
    • From the sub-site home page, navigate to: “Library Tools” -> “Library” -> “Library Settings” -> “Workflow Settings”.
    • From this screen you should see the “ExcelRefreshWorkflow” item in the “Select a workflow template:” list. Select that item, complete the remaining configuration settings and click “OK”.
    • For each document desired, click on the document dropdown and select “Workflows”.
    • Click on the “ExcelRefreshWorkflow”
    • Setup the appropriate configuration settings and click the “Start Workflow” button.
    • NOTE: All activity related to the workflow (including the execution history) will be stored in the associated “Workflow History”.

Attached is a sample workflow that will open an Excel file in document library, refresh the data connection and save the file as a new version in the document library on a scheduled interval. (422.11 kb)


Sharepoint | Workflow Foundation

Sample Code to Get a Workflow Instance from Persistence DB

by 6. July 2009 03:30

static MyWorkflow GetMyWorkflowInstance(WorkflowRuntime workflowRuntime, Guid instanceID)


  /* ================================================================================ */

  // This method is a workaround to get an instance of a workflow from the persistence

  // data store, since there is no direct method to get the workflow instance (i.e.

  // the workflowRuntime.GetWorkflow(instanceId) method gets the workflow model not

  // the actual workflow in it's persisted state.

  /* ================================================================================ */


  MyWorkflow activity;

  SqlConnection cn = new SqlConnection(


  SqlCommand cmd = new SqlCommand(

    "select state from InstanceState where uidInstanceID = @InstanceID", cn);

  cmd.Parameters.AddWithValue("@InstanceID", instanceID.ToString());


  byte[] byt = (byte[])cmd.ExecuteScalar();


  System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter

    = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();


    = System.Workflow.ComponentModel.Serialization.ActivitySurrogateSelector.Default;

  System.IO.MemoryStream stream = new System.IO.MemoryStream(byt);

  stream.Position = 0;

  using (System.IO.Compression.GZipStream stream2

    = new System.IO.Compression.GZipStream(stream,

      System.IO.Compression.CompressionMode.Decompress, true))


    // Here we can finally do the real work to deserialize... 


      = (MyWorkflow)System.Workflow.ComponentModel.Activity.Load(stream2

      , workflowRuntime.CreateWorkflow(typeof(MyWorkflow)).GetWorkflowDefinition()

      , formatter);


  return activity;

  /* ================================================================================ */



Tags: ,

ASP.Net | C# | Workflow Foundation

Workflow Foundation Testing

by 12. December 2008 20:31

This version was having troubles: (144.31 kb)

This version works for both WFWeb and WFPersistenceSample, also added WFMonitor (from SDK WCF_WF_CardSpace_Samples): (345.36 kb)


Workflow Foundation

Building Workflow Services (WF+WCF) with Visual Studio 2008

by 13. August 2008 15:25

WEBCAST: Building Workflow Services (WF+WCF) with Visual Studio 2008

The Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) are two very relevant technologies within .NET 3.x for Public Sector applications. WCF represents a total unification layer for building connected systems and WF provides a powerful foundation for process reengineering. Combine them and you have an unbelievable set of capabilities for building robust enterprise application that involve both process automation as well as human and machine to machine workflow and process communication. Come learn the basis of how to build WCF services using workflow foundation in Visual Studio 2008.


Friday, February 22, 2008

2:00P-3:30P EST (11:00A-12:30P PST)

Register at this link:


Windows Communication Foundation | Workflow Foundation

Workflow Hosted via Windows Communication Foundation

by 11. August 2008 22:22

Instance management techniques for WFC:

Windows Communication Foundation (WCF), Windows Workflow Foundation (WF) and Windows CardSpace Samples

Brief Description
Samples for Windows Communication Foundation (WCF), Windows Workflow Foundation (WF) and Windows CardSpace


Windows Communication Foundation | Workflow Foundation

Workflow Foundation

by 11. August 2008 18:18

Workflow Persistence to SQL Server database, recommended to create two separate databases and run scripts as shown below. 

WorkflowPersistence (db) WorkflowPersistence.bak (1.46 mb) SqlPersistenceService_Schema.sql (4.20 kb) SqlPersistenceService_Logic.sql (23.34 kb)

WorkflowTracking (db) WorkflowTracking.bak (1.89 mb) Tracking_Schema.sql (49.61 kb) Tracking_Logic.sql (372.66 kb)

Note: The default location of attached SQL scripts listed above is: C:\Windows\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\EN




Workflow Foundation