I have a WCF service with a private constructor. If I’m not wrong, constructors must be parameterless in WCF and the parameter I need is the caller’s name (or caller’s method name), so I can assign a few readonly fields.
Is there a way that I can get the caller’s name — or the method that invoked it? I was playing around with OperationContext.Current, but without any luck.
I wouldn’t recommend accessing the stack trace for performance reasons.
WCF service constructors only need to be parameterless if you are using the default ServiceHostFactory. You can specify a custom service factory in your .svc file like this:
The process to creating your class in a custom way goes like this:
I have used this to delegate creation to an IoC container.