简体   繁体   English

WF 4.5应用动态更新异常

[英]WF 4.5 Apply Dynamic Update Exception

After creating StateMachine Workflow with few steps i wanted to try using DynamicUpdate. 用几步创建StateMachine工作流后,我想尝试使用DynamicUpdate。 By following the instructions i create update map, but when i try to apply it i get the following errors: 按照说明,我创建了更新地图,但是当我尝试应用它时,出现以下错误:

An unhandled exception of type 'System.Activities.DynamicUpdate.InstanceUpdateException' occurred in System.Activities.dll Additional information: The update map does not match the workflow definition. System.Activities.dll中发生了类型为'System.Activities.DynamicUpdate.InstanceUpdateException'的未处理异常。其他信息:更新映射与工作流定义不匹配。 Please make sure that this is the correct map for this definition, and that the serialized map has not been manually altered. 请确保这是此定义的正确映射,并且未手动更改序列化映射。

Troubleshooting details: IdSpace with owner '' has '2' members; 故障排除详细信息:具有所有者“”的IdSpace具有“ 2”个成员; expected '1'. 预期为“ 1”。

StateMachine does not support Dynamic Update, if the Trigger of an existing Transition is modified, or the Condition or Action activity is reassigned to a new Transition. 如果修改了现有转换的触发器,或者将条件或动作活动重新分配给新的转换,则StateMachine不支持动态更新。


All i did in the new version is adding epmty State and connect Pointers to it. 我在新版本中所做的就是添加epmty State并将Pointers连接到它。 Still the persisted workflows give this exception. 持久的工作流仍然会给出此例外。

Try that: 试试看:

public static void UpdateWorkflowDynamic(string xaml)
    {
        StringReader sr = new StringReader(xaml);
        XmlReader xmlReader = XmlReader.Create(sr);
        XamlXmlReaderSettings settings = new XamlXmlReaderSettings
        {
            LocalAssembly = typeof(BookmarkDesign).Assembly
        };
        XamlReader xamlReader = new XamlXmlReader(xmlReader, settings);
        ActivityXamlServicesSettings XamlSettings = new ActivityXamlServicesSettings
        {
            CompileExpressions = true
        };
        Activity newActivity = ActivityXamlServices.Load(xamlReader, XamlSettings);


        sr = new StringReader(xaml);
        xmlReader = XmlReader.Create(sr);
        xamlReader = new XamlXmlReader(xmlReader, settings);
        ActivityBuilder activityBuilder = (ActivityBuilder)XamlServices.Load(ActivityXamlServices.CreateBuilderReader(xamlReader));
        DynamicUpdateServices.PrepareForUpdate(activityBuilder);
        DynamicUpdateMap updateMap = DynamicUpdateServices.CreateUpdateMap(activityBuilder);
        WorkflowIdentity newIdentity = new WorkflowIdentity
        {
            Name = "Update",
            Version = new Version(2, 0, 0, 0)
        };
        WorkflowApplicationInstance instance = WorkflowApplication.GetInstance(Guid.Parse("yourGuid"), GetInstance().InstanceStore);
        WorkflowApplication wfApp = new WorkflowApplication(newActivity, newIdentity);

        wfApp.Load(instance, updateMap);
        wfApp.Unload();
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM