开发者

WCF Dataservice hosting issue with vs2010

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开发者_JS百科 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


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();
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜