In my server side console program, multiple ServiceHost objects are created and working in PerSession mode, not singleton. Therefore, a new server side object will be created when a new session started.
The problem is: How can I know which is the right ServiceHost object linked with the new created server side object? I do need this link information for further operations.
Can I get the ServiceHost information from the new created server side object? By converting it into another interface or class? Or, can I hook the instance creating process of ServiceHost?
Any idea?
Thanks a lot.
Try the OperationContext
- it has a .Host
property:
var host = OperationContext.Current.Host;
See the MSDN documentation for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With