Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 273625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:29:07+00:00 2026-05-12T00:29:07+00:00

I have a WCF service with a private constructor. If I’m not wrong, constructors

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T00:29:07+00:00Added an answer on May 12, 2026 at 12:29 am

    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:

    <%@ ServiceHost Language="C#" Debug="true"
       Service="Namespace.To.Service"
       Factory="Namespace.To.ServiceFactory" %>
    

    The process to creating your class in a custom way goes like this:

    1. Your ServiceHostFactory creates an instance of your custom ServiceHost in CreateServiceHost
    2. ServiceHost overrides OnOpening and adds a custom IServiceBehavior to Description.Behaviors (Description is a property on the base class)
    3. Your IServiceBehavior implements ApplyDispatchBehavior and enumerates serviceHostBase.ChannelDispatchers, checking if each is a ChannelDispatcher.
      • Each ChannelDispatcher’s Endpoints property is enumerated and it’s DispatchRuntime.InstanceProvider is changed to a custom IInstanceProvider
    4. The custom IInstanceProvider creates the instance in GetInstance

    I have used this to delegate creation to an IoC container.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WCF service with the following configuration: <system.serviceModel> <behaviors> <serviceBehaviors> <behavior name=MetadataEnabled>
I have a WCF Service that should not enter the faulted state. If there's
I have a WCF service that I have to reference from a .net 2.0
I have a WCF service hosted for internal clients - we have control of
I have a WCF service and I want to expose it as both a
I have a WCF service running on the IIS with a ServiceHostFactory. It's running
I have a WCF service, hosted in IIS 7.0 that needs to run database
I have a WCF service which will be hosted under IIS. Now I have
I have a WCF service that is hosted in a windows application. The service
I have a WCF Service that exposes a method GetCustomers(). The internals of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.