开发者

ServiceHost Class constructor

I'm refering the book Microsoft Windows Communication Foundation Step By Step. It says that

If you omit the base address information in the ServiceHost constructor, like this:

ServiceHost productsServiceHost = new ServiceHost(typeof(ProductsServiceImpl));

the WCF runtime will just use the 开发者_如何学Pythonaddress information specified in the application configuration file, and automatically listen for requests on all configured endpoints.

But when I try to declare the ServiceHost class using VS 2010, it gives only 2 option for ServiceHost class. Both of which need base url. Is above constructor removed in VS 2010 or am I missing something?


There are indeed two constructors:

  • public ServiceHost(Object singletonInstance, params Uri[] baseAddresses)
  • public ServiceHost(Type serviceType, params Uri[] baseAddresses)

However, note that they both use a params argument for the base addresses. This means it is valid to not pass anything at all.


Figured it out. It was missing the baseAddress element.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜