locked
"The key 'LocalizedPerfCounter' does not exist in the appSettings" when creating Socket RRS feed

  • Question

  • Hi all,

    Some time ago, I've installed the nuGet package for self-hosted signalR applications on a project. Today, I went to start a completely unrelated project, one that does not have that package (or any package at all), and has absolutely nothing to do with owin, asp.net, signalR or anything else related to that package.

    Now in this project, when I try to create a Socket, I get an InvalidOperationException: "The key 'LocalizedPerfCounter' does not exist in the appSettings".

    The exception seems to be handled and the program proceeds, but it's annoying.

    Also, I'm seriously concerned. Here I'm not trying to create some arcane ASP.NET thing that calls down into a dozen layers and six different configuration frameworks before actually getting to the TCP stack. I'm doing a plain straight new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp).

    How is it possible for a nuGet package that installs unrelated DLLs to another solution entirely to affect something that resides in the basic System.dll? What business does it have interfering with very low-level network calls?

    Monday, December 1, 2014 9:30 AM

Answers

  • Hello Zappo,

    >>I'd like to understand exactly what the CLR is attempting to do here and why.

    If you mean that you want know why when you create a Socket constructor, it throws the "The key 'LocalizedPerfCounter' does not exist in the appSettings" and this error occurs at run time, you could check this blog, it shows now we can debug into the .NET Framework libraries step by step to see the exact code.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fred Bao Thursday, December 18, 2014 6:08 AM
    Wednesday, December 3, 2014 6:09 AM

All replies

  • Hello Zappo,

    For this InvalidOperationException, please check this hotfix to see if you are under those scenario:

    http://support.microsoft.com/kb/2784156

    >> How is it possible for a nuGet package that installs unrelated DLLs to another solution entirely to…

    For this, since it is related with the NuGet, I suggest that you could post it to the NuGet forum,

    https://nuget.codeplex.com/workitem/list/basic

    The current forum is specifical for .NET Framework Class Libraries.

    Discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection.

    Thanks&Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, December 2, 2014 2:01 AM
  • Thanks for your answer. I suppose it is possible for an automatic update to have inserted that hotfix; indeed, if I add that configuration entry, the problem goes away. However, now I have to have a config file for my application, something I didn't have before. Annoying.

    The reason I posted this in the libraries forum is that, leaving aside NuGet, I'm concerned with handled exceptions happening inside a Socket constructor for no good reason. I reiterate - this is a low-level call; I would expect it to be a thin wrapper around socket(), not to attempt to set up layers of middleware and certainly not to require configuration. I'd like to understand exactly what the CLR is attempting to do here and why.

    Tuesday, December 2, 2014 8:13 AM
  • Hello Zappo,

    >>I'd like to understand exactly what the CLR is attempting to do here and why.

    If you mean that you want know why when you create a Socket constructor, it throws the "The key 'LocalizedPerfCounter' does not exist in the appSettings" and this error occurs at run time, you could check this blog, it shows now we can debug into the .NET Framework libraries step by step to see the exact code.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fred Bao Thursday, December 18, 2014 6:08 AM
    Wednesday, December 3, 2014 6:09 AM
  • Thanks, that's helpful. It looks like debugging into the .NET Framework code is only supported for 4.5.1 (I'm using 3.5).

    I downloaded the source, though, and I see that at some point the constructor will look into configuration to see if performance counters are enabled. But the text "LocalizedPerfCounter" does not exist anywhere in the sources. I don't see how an InvalidOperationException could be thrown at that point, either. Most likely, there were significant changes between 3.5 and 4.5.1.

    I'm afraid I can't spend more time on this... thanks for your help.

    Wednesday, December 3, 2014 7:53 AM
  • I've found this discussion investigating this exact error message in the code that was resolving server name.

    This is an "exception-based logic" bug in the framework. This kind of framework bugs are rare, but if you bumped into one, they can make debugging sessions a living hell.

    A workaround for my desktop application was to add the requested key to the app.config

      <appSettings>
          <add key="LocalizedPerfCounter" value="false"/>
      </appSettings>


    Monday, April 13, 2015 9:57 PM