开发者

Sharing Console Application object to Self-Host WCF Service

I need to share my application statistics via a wcf service. I'm able to self-host my wcf service but ServiceHost object constructor is default leaving me to unable to initialize other member variables of my service.

Sample:

public interface IService
{
   //some op开发者_如何学Pythonerations here 
}

public class Service : IService
{
  object myObject;
  //implementation of IService
}

myObject is my console application object ( List ) and I wanted to make my service to be able to look into it. Is there any way I can reference it on my WCF Service?


You could provide an instance of the service yourself by creating a custom IInstanceProvider.


You could use this approach to the get handle on your ServiceHost instance in your service implementation code:

ServiceHostBase base = OperationContext.Current.Host;

Now you have a link to to your service host - anything publicly available and accessible can be read (preferably not set, since there might be many service class instances running).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜