C# 创建长期运行的工作流服务
我试图学习本教程,以了解更多关于工作流服务及其工作方式的信息。现在我可能是疯了,但我在教程的客户端部分遇到了问题(我很想把这个问题归咎于教程,而不是我自己)。StartOrderClient初始化和AddItemClient上出现引用错误。这只是教程中一个稍微不完整的步骤,还是我遗漏了什么 我事先非常感谢你 下面是我的订单客户端控制台程序C# 创建长期运行的工作流服务,c#,workflow-foundation,workflowservice,C#,Workflow Foundation,Workflowservice,我试图学习本教程,以了解更多关于工作流服务及其工作方式的信息。现在我可能是疯了,但我在教程的客户端部分遇到了问题(我很想把这个问题归咎于教程,而不是我自己)。StartOrderClient初始化和AddItemClient上出现引用错误。这只是教程中一个稍微不完整的步骤,还是我遗漏了什么 我事先非常感谢你 下面是我的订单客户端控制台程序 using System; using System.Collections.Generic; using System.Linq; using System
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ServiceModel;
using System.ServiceModel.Activities;
namespace OrderClient.OrderService
{
class Program
{
static void Main(string[] args)
{
// Send initial message to start the workflow service
Console.WriteLine("Sending start message");
StartOrderClient startProxy = new StartOrderClient();
string orderId = startProxy.StartOrder("Kim Abercrombie");
// The workflow service is now waiting for the second message to be sent
Console.WriteLine("Workflow service is idle...");
Console.WriteLine("Press [ENTER] to send an add item message to reactivate the workflow service...");
Console.ReadLine();
// Send the second message
Console.WriteLine("Sending add item message");
AddItemClient addProxy = new AddItemClient();
AddItem item = new AddItem();
item.p_itemId = "Zune HD";
item.p_orderId = orderId;
string orderResult = addProxy.AddItem(item);
Console.WriteLine("Service returned: " + orderResult);
}
}
}
以下是错误。StartOrderClient和AddItemClient,我认为它们在教程中没有定义
找不到类型或命名空间名称“StartOrderClient”(是否缺少using指令或程序集引用?)
找不到类型或命名空间名称“AddItemClient”(是否缺少using指令或程序集引用?若要解决此错误,请打开Service1.xamlx文件。单击
ReceiveStartOrder
并将ServiceContractName
属性更改为{http://tempuri.org/}IStarOrder
(通常是{http://tempuri.org/}IService}
默认设置)。对ReceiveAddItem
活动(IAddItem
)执行相同的操作
重建解决方案。在控制台项目中,右键单击OrderService
服务引用并更新它
注意:教程中充满了错误,我仍在学习。一旦我成功地完成并记录了缺失的步骤和不准确之处,我将更新此答案,并可能包括一个带有修订教程的博客帖子链接
对于任何试图学习本教程的人,更好的选择是遵循。我将此代码用于main方法
static void Main(string[] args)
{
// Send initial message to start the workflow service
Console.WriteLine("Sending start message");
ServiceClient proxy = new ServiceClient();
string orderId = proxy.StartOrder("Kim Abercrombie");
// The workflow service is now waiting for the second message to be sent
Console.WriteLine("Workflow service is idle...");
Console.WriteLine("Press [ENTER] to send an add item message to reactivate the workflow service...");
Console.ReadLine();
// Send the second message
Console.WriteLine("Sending add item message");
AddItem item = new AddItem();
item.p_itemId = "Zune H";
item.p_orderId = orderId;
string orderResult = proxy.AddItem(item);
Console.WriteLine("Service returned: " + orderResult);
}
什么样的引用错误?也就是说,具体来说,您的错误是什么?错误发生在哪里/何时?好的……您仍然需要更具体一些。错误窗口应该告诉您找不到什么类型或名称空间。我需要这些信息来帮助您。询问显而易见的问题,但是您是否向工作流服务添加了服务引用并指定了
OrderService
作为名称空间?@IvanS如果您已将服务引用添加到您的客户机项目中,您需要添加一个“using”语句,类似于using OrderService