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 8527643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:36:51+00:00 2026-06-11T08:36:51+00:00

We have a worker service running from console application in c#, for development we

  • 0

We have a “worker” service running from console application in c#, for development we were always running a single instance of this service, which fetches chunks of data and performs some calculations, these chunks of data are provided by another service (which keeps track of how much data is left etc.)

Now in QA we want to run multiple instances of the “worker” service simultaneously (on the same machine).However we are get an exception as soon as the second instance is launched:

The TransportManager failed to listen on the supplied URI using the
NetTcpPortSharing service: the URI is already registered with the
service.

We are using netTcpBinding and the endpoint address is hardcoded into the app.config and remains the same and because of that I assume we are getting this error.

<services>
    <service behaviorConfiguration="CoreBehavior" name="WorkerService">
        <endpoint address="net.tcp://localhost:8001/WorkerAssignment" binding="netTcpBinding" contract="IWorkerService" bindingConfiguration="CoreTcpBinding"/>
    </service>
</services>
<bindings>
    <netTcpBinding>
        <binding name="CoreTcpBinding" portSharingEnabled="true">
            <security mode="None"/>
        </binding>
    </netTcpBinding>
</bindings> 

Application code :

var host = new ServiceHost(typeof(WorkerService));
host.Open();

How do we provide a different URI for each instance so that atleast the port will remain the same ?

OR If there is a different way to run multiple instances of the same service?

  • 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-06-11T08:36:53+00:00Added an answer on June 11, 2026 at 8:36 am

    If you want to have multiple instances of the service than it is enough to have single service host – just decorate you WorkerService with ServiceBehaviorAttribute

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Percall)] 
    public class WorkerService : IWorkerService 
    {
      //...service data
    }
    

    This will make sure that every call to the service will first create new instance of the service. Other ways of creating service class can be found here

    If, however you would like to have multiple service hosts than it is impossible to have two service hosts that will host same service on completely the same url.

    Another case would be if you want to have one service host hosting the same service on multiple endpoints with the same base address and custom uri’s. In this case you can make use of overloaded ServiceHost constructor or investigate methods AddBaseAddress , AddServiceEndpoint. Or if you want to do it from configuration file than here’s simple example with your code slightly modified

    <service behaviorConfiguration="CoreBehavior" name="WorkerService">
        <endpoint address="WorkerAssignment" binding="netTcpBinding" contract="IWorkerService"/>
        <endpoint address="QAWorkerAssignment" binding="netTcpBinding" contract="IWorkerService"/>
      <host>
        <baseAddresses>
          <add baseAddress="net.tcp://localhost:8001/" />
        </baseAddresses>
      </host>
    </service>
    

    with this configuration you will have two endpoints for your service

    net.tcp://localhost:8001/WorkerAssignment

    net.tcp://localhost:8001/QAWorkerAssignment

    • 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 method that's running in a worker thread I spin
I have a windows service running as part of my application. If I wish
I have a service which creates a thread. This thread does some work and
I have a Service in my application which is designed to run every 10
I have a service hosted in a Worker Role in Azure. Clients connect over
I have a worker thread spawned from a GUI (for GUI performance), how do
We have a .NET 3.5 Web Service ( not WCF) running under IIS. It
I am running Windows 7 Ultimate 64 bit. I have a windows service (written
We have an ASP.NET application that queues some of its long-running operations (generating reports,
I've written an ASP.NET 2.0 web service which is consumed by a web application

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.