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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:36:04+00:00 2026-05-15T02:36:04+00:00

I have a working ServiceHost with a single NetTcpBinding and a single endpoint. I

  • 0

I have a working ServiceHost with a single NetTcpBinding and a single endpoint.

I .Close() it. Then, I create a new ServiceHost instance with the exact same configuration as the first one. Then, when I try to .Open() the new instance I’m getting this very awkward exception:

System.ArgumentException occurred
  Message=Instance 'LobbyService@net.tcp:||localhost:2718|game|' already exists in CounterSet 'e829b6db-21ab-453b-83c9-d980ec708edd'.
Parameter name: InstanceName
  Source=System.Core
  ParamName=InstanceName
  StackTrace:
       at System.Diagnostics.PerformanceData.CounterSetInstance..ctor(CounterSet counterSetDefined, String instanceName)

Has anybody seen that before? Is it a bug in the .NET Framework (I’m using 4.0, by the way)?

Probably relevant info about my ServiceHost:

  • No clients are connected to the host, when it is first closed;
  • A custom IInstanceProvider is used to create instances;
  • The binding’s ReliableSession is turned on;
  • The service type is marked with the ServiceBehavior below;

.

[ServiceBehavior(
IncludeExceptionDetailInFaults = true,
InstanceContextMode=InstanceContextMode.PerSession,
ConcurrencyMode=ConcurrencyMode.Reentrant,
UseSynchronizationContext = false
)]

I’m open to reveal any extra info you might want to know about the application.

Update 1 I compiled the application targeting .NET 3.5 and the error did NOT happened. Unfortunately, I have to deactivate everything that relied in Task‘s.

Update 2 I logged a bug at Microsoft Connect about this issue. I guess this question is already answered now.

  • 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-15T02:36:04+00:00Added an answer on May 15, 2026 at 2:36 am

    This is a bug with .NET Framework 4.0. I logged a bug at Microsoft Connect about it.

    Here’s the answer from Microsoft:

    This looks like a known problem caused
    by timing issues in tight Close/open
    sequence of ServiceHost. ServiceHost
    maintains some performance counters
    that might not get garbage collected
    leading to this exception. I assume
    you are using .Net Framework 4.0?
    Please try to workaround by doing a
    forced GC before you open the second
    ServiceHost:

    GC.Collect() 
    GC.WaitForPendingFinalizers()
    

    Doing what they advised solved the problem. I hope it gets fixed in a later release.

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

Sidebar

Related Questions

I'm pretty new to NHibernate. I have working many to many mappings. they look
Have been working on this question for a couple hours and have come close
I have a problem related to creating an instance of a WCF ServiceHost withing
Running a ServiceHost with a single contract is working fine like this: servicehost =
I have working on an application which captures screen shots and create video from
I'm using Entity Framework Code First and whilst I have working code, I'm having
I have working Ajax call. Now I need to parametrize it as the same
I have working with a project and i added a share button to product
I have working website in PHP with a MySQL backend which has several tables
I have working code of js, it shows different div for selected option. <html>

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.