3

我们目前正在将我们的解决方案从 .net 3.5 升级到 .net 4.5。在此期间我们面临以下错误

'System.Workflow.ComponentModel.Compiler.TypeProvider' 已过时:'System.Workflow.* 类型已弃用。相反,请使用 System.Activites.* 中的新类型

下面的代码创建一个 TypeProvider 以允许在我们拥有的 WF 规则引擎中使用其他类型。这在 RulesValidaton 构造函数中使用,如下面的代码所示

TypeProvider typeProvider = new TypeProvider(null);
typeProvider.AddAssemblyReference(typeof(T).Assembly.Location);
typeProvider.AddAssemblyReference(typeof(ValidationClass<T>).Assembly.Location);

RuleValidation ruleValidation = new RuleValidation(typeof(ValidationClass<T>), typeProvider);

我用谷歌搜索了如何使用 System.Activities.* 命名空间来实现相同的目标,但找不到任何东西。请指导我找到 .net 4.5 中 TypeProvider 类的适当替代品。

4

1 回答 1

2

This functionality has been completely redone in .NET 4.5. Now you are able to run multiple instances, and Micorosft has done a great job (believe it or not) in their .NET 4.5 Examples to show how this can be done.

http://msdn.microsoft.com/en-us/library/jj205427.aspx

Here is some of the key code, and obviously would be different for the different types of workflows, to do something to a particular "instance" of the workflow.

ActivityBuilder wf = StartUpdate("StateMachineNumberGuessWorkflow.xaml");

StateMachine sm = wf.Implementation as StateMachine;

于 2013-04-15T21:15:34.583 回答