Windows窗体中托管的WCF数据服务

时间:2010-05-28 05:17:03

标签: wcf

我想以Windows格式托管WCF数据服务(以前称为ADO.NET数据服务)。这可能吗?如果是,那么有没有博客,谈论它? 我知道WCF可以在Windows窗体中托管,但我不确定WCF数据服务,因为我看到的所有示例都要求创建ASP.NET Web项目。

-Brajesh

1 个答案:

答案 0 :(得分:2)

在WinForms应用程序中托管WCF数据服务非常容易(或者在我的情况下是单元测试)。

// add reference to System.Data.Services

// identify your endpoint uri
Uri endpoint = new Uri("http://localhost:12345/MyDataService");
// create the data service host
DataServiceHost host = new DataServiceHost(typeof(MyDataService), new Uri[] { endpoint });