private void cmdUpdateInstance_Click(object sender, RoutedEventArgs e)
      {
          SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore();

          instanceStore.ConnectionString =
              @"Data Source=(LocalDB)\v11.0;Initial Catalog=WFPersist;Integrated Security=True";

          WorkflowApplicationInstance wfInstance =
              WorkflowApplication.GetInstance(new Guid(txtUpdateInstance.Text), instanceStore);

          DataContractSerializer s = new DataContractSerializer(typeof(DynamicUpdateMap));

          using (FileStream fs = File.Open(txtUpdateMapFile.Text, FileMode.Open))
          {
              updateMap = s.ReadObject(fs) as DynamicUpdateMap;
          }

          var wfApp =
              new WorkflowApplication(new MovieRentalProcess(),
                                      new WorkflowIdentity
            {
                Name    = "v2MovieRentalProcess",
                Version = new System.Version(2, 0, 0, 0)
            });

          IList <ActivityBlockingUpdate> act;

          if (wfInstance.CanApplyUpdate(updateMap, out act))
          {
              wfApp.Load(wfInstance, updateMap);
              wfApp.Unload();
          }
      }
        /// <summary>
        ///
        /// </summary>
        /// <param name="definitionPath"></param>
        /// <param name="mapPath"></param>
        /// <param name="connectionString"></param>
        /// <param name="instanceId"></param>
        public static void Update(String definitionPath, String mapPath, String connectionString, Guid instanceId)
        {
            // Store
            SqlWorkflowInstanceStore instanceStore = new SqlWorkflowInstanceStore
            {
                ConnectionString = connectionString
            };

            // Instance to update
            WorkflowApplicationInstance wfInstance = WorkflowApplication.GetInstance(instanceId, instanceStore);

            // Load update map
            DynamicUpdateMap       updateMap;
            DataContractSerializer s = new DataContractSerializer(typeof(DynamicUpdateMap));

            using (FileStream fs = File.Open(mapPath, FileMode.Open))
            {
                updateMap = s.ReadObject(fs) as DynamicUpdateMap;
            }
            // if (updateMap == null) return; // Throw

            WorkflowApplication wfApp =
                new WorkflowApplication(LoadActivityBuilder(definitionPath).Implementation);

            IList <ActivityBlockingUpdate> act;

            if (wfInstance.CanApplyUpdate(updateMap, out act))
            {
                wfApp.Load(wfInstance, updateMap);
                wfApp.Unload();
            }
        }