tags:

views:

128

answers:

1

Hi,

I want to host a WCF Data Service (formerly known as ADO.NET data Service) in windows form.Is it possible? If yes,then is there any blog, which talks about it? I know WCF can be hosted in Windows Form, but I am not sure about WCF data service, as all the examples I see, is asking to create ASP.NET web project.

-Brajesh

A: 

It is very easy to host a WCF Data Service in a WinForms application (or in my case a unit test).

// 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 });
Tom Brothers
Thanks a lot! Your solution worked and saved lot of my time.-Brajesh