WCF Dataservice hosting issue with vs2010

256 views Asked by At

I have created WCF Data service and I hosted in visual studio ASP.net development server.My problem is that my service will run only when I build my application through VS2010, if I try running exe using debug/release folder dataservice is not launching. It should run when I click on my application exe file.

Below code sinnpet describe how I starting my data service.

WebServiceHost dbServiceHost= new  WebServiceHost(typeof(MyDataService));

dbServiceHost.Open();

Any early help would be appreciated

1

There are 1 answers

2
marc_s On BEST ANSWER

You need to use the DataServiceHost (in assembly System.Data.Services; descends from WebServiceHost) to host your WCF Data Service:

using System.Data.Services;

Uri[] baseAddresses = new Uri[1];
baseAddresses[0] = new Uri(baseAddress);

using(DataServiceHost host = new DataServiceHost(typeof(YourDataService), baseAddresses))
{
    host.Open();
    Console.WriteLine("DataService up and running.....");

    Console.ReadLine();
    host.Close();
 }