سؤال

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top