上下文不可用?
我正在尝试在 wf4 中创建自定义活动。我找到了一个教程/示例,并一直使用它来开始,但是我似乎遇到了问题。
public sealed class SaveRequest : NativeActivity {
// Define an activity input argument of type string
[RequiredArgument]
public InArgument<Request> Request { get; set; }
// If your activity returns a value, derive from CodeActivity<TResult>
// and return the value from the Execute method.
protected override void Execute(NativeActivityContext context) {
Request Request = this.Request.Get(context);
Request.Id = Guid.NewGuid();
Request.Title = "New Test";
RequestMonkeyRepository Rep = new RequestMonkeyRepository();
Rep.save(Request);
}
}
分配 guid 时,上面的代码总是会出错并显示空对象实例。我认为这是因为我尚未将请求对象传递给工作流程,但我看不到他们在示例中是如何做到这一点的。
我正在运行控制台应用程序,我的执行代码如下
WorkflowInvoker.Invoke(new RequestMonkeyTest1.TestWorkflow());
Im playing around trying to create a custom activity in wf4. I found a tutorial / example and have been using this to get started, however i seem to have a problem.
public sealed class SaveRequest : NativeActivity {
// Define an activity input argument of type string
[RequiredArgument]
public InArgument<Request> Request { get; set; }
// If your activity returns a value, derive from CodeActivity<TResult>
// and return the value from the Execute method.
protected override void Execute(NativeActivityContext context) {
Request Request = this.Request.Get(context);
Request.Id = Guid.NewGuid();
Request.Title = "New Test";
RequestMonkeyRepository Rep = new RequestMonkeyRepository();
Rep.save(Request);
}
}
The code above always errors out with an null object instance when assigning the guid. Im presuming its because i havent passed the request object to the workflow, but i cant see how they did this in the example.
Im running a console app and my execution code is below
WorkflowInvoker.Invoke(new RequestMonkeyTest1.TestWorkflow());
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否将工作流程中的 Request InArgument 设置为返回 Request 对象实例的某个表达式?如果没有,请尝试在表达式中添加“new Request()”并再次运行您的工作流程。
Did you set the Request InArgument in your workflow to some expression that returns an instance of a Request object? If not try adding "new Request()" in the expression and run your workflow again.