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

  • SEARCH
  • Home
  • 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 6790469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:43:44+00:00 2026-05-26T17:43:44+00:00

When trying to host my WCF service using Net Tcp channel through Windows Console,

  • 0

When trying to host my WCF service using Net Tcp channel through Windows Console, I have to comment the 4 lines of code everytime I want to make my service discoverable.

class Program
{
    static void Main(string[] args)
    {
        using (ServiceHost host = new ServiceHost(typeof(MyLibrary.MyService)))
        {
            // The following four lines of code currently break the ability to update or recreate a reference to this service
            // Configure the custom authorization policy which will invoke the custom role-permission model

            **//List<IAuthorizationPolicy> policies = new List<IAuthorizationPolicy>();
            //policies.Add(new CustomAuthorizationPolicy());
            //host.Authorization.ExternalAuthorizationPolicies = policies.AsReadOnly();
            //host.Authorization.PrincipalPermissionMode = PrincipalPermissionMode.Custom;**

            // Instantiate the service listener
            host.Open();
            Console.WriteLine("The service is running and is listening on:" + Environment.NewLine);

            // Iterate through all the configured service end points
            foreach (ServiceEndpoint endPoint in host.Description.Endpoints)
            { // Do My Work
            }
            Console.WriteLine(Environment.NewLine + "Press any key to stop the service");
            Console.ReadKey();

            host.Close();
        }
    }
}

I can comment those 4 lines of code and make the service discoverable, add and update service references, etc. and then revert the code when I am done.

In Production, I am hosting the service through Windows Service so practically there is no show stopper.

I am trying to find out why would I have to comment those 4 lines of code everytime and is there a way to resolve this issue, though I have a way of bypassing this issue. Any hints would be a great help and appreciated.

  • 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-26T17:43:45+00:00Added an answer on May 26, 2026 at 5:43 pm

    Without knowing specifically what goes into the CustomAuthorizationPolicy it will be hard to say exactly, but my best guess would be that your policy is rejecting calls to the MEX endpoint because they do not meet your authorization requirements. If as you’re saying you are checking roles, this is likely because the MEX endpoint is not setup by default to support Windows authentication, so you would be getting an anonymous call and your eventual IsInRole check will fail because of that.

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

Sidebar

Related Questions

I'm trying to host a WCF service inside a console app using Castle-Windsor 2.5
I am trying to host a WCF service, using NetTcpBinding in a Windows service.
I'm trying to host a WCF service with net.tcp binding within an IIS 7.5
I am trying to host a WCF web service in IIS using Windows Authentication.
I am trying to host WCF serviec in managed Windows Service. Basically i have
I have a WCF service. I am trying to host the service in a
I'm trying to host a WCF Service inside a Windows Service which I am
WCF newbie here... I'm trying to self-host a WCF service using NetTcpBinding. Based on
I am trying to host a WCF service on a windows service.Basically WCF service
I am trying to publish a WCF service that sends to a NSB host.

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.