Question

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

Was it helpful?

Solution

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();
 }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top