Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly." on RouteTable.Routes.MapHubs();

I'm working with SignalR 1.1.2 version and Windsor Castle in an AspNet MVC 4 application. My problem is that this error message is showing up since I moved to the newer SignalR version.

"The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly."

in the line

    RouteTable.Routes.MapHubs();

This is the RegisterHubs class

public static class RegisterHubs
{
    public static void Start()
    {
        var signalrDependencyContainer = new WindsorContainer().Install(new HubsInstaller());
        var signalrDependency = new SignalrDependencyResolver(signalrDependencyContainer.Kernel);
        GlobalHost.DependencyResolver = signalrDependency;
        RouteTable.Routes.MapHubs();
    }
}

I already tried a few things I've found in internet like:

lodctr /R
cd C:\Windows\Inf\.NETFramework
lodctr corperfmonsymbols.ini

But I'm still getting the same error message. Any ideas?

I'm using dotnet framework 4.5.

This is the stacktrace

at System.Diagnostics.PerformanceCounter.InitializeImpl()

Thanks!

UPDATE I'm adding the screenshots requested by Drew. enter image description here

enter image description here

enter image description here

like image 358
polonskyg Avatar asked Jul 08 '13 18:07

polonskyg


3 Answers

So based on the information you've provided it is clear that these are first chance exceptions being thrown when SignalR is attempting to create the performance counters but doesn't have the rights to do so with the identity that the process is running under. You can safely ignore these exceptions, but you obviously won't get performance counter data.

If you want to create the performance counters you need to make sure the identity of your application belongs to the Performance Counter Users group when it's running. Either that or you need to use the utility application provided in the Microsoft ASP.NET SignalR Utilities NuGet package that allows you to create the counters out of band. Just install the package and run the command:

signalr ipc
like image 109
Drew Marsh Avatar answered Oct 05 '22 00:10

Drew Marsh


Drew Marsh's response, solved the problem for me, too. Here are additional details describing how to go about running the signalr command:


Use the package manager to install SignalR Utils:

  1. In VS: Tools -> Library Package Manager -> Package Manager Console
  2. From the command line, type:

    PM> Install-Package Microsoft.AspNet.SignalR.Utils

  3. Running the IDE as an Administrator, run:

    PM> signalr ipc

Administrator permissions are needed to do run the performance counters installation command (signalr ipc) - running without doing so results in this error:

Error: System.Security.SecurityException: Requested registry access is not allowed. at Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) at System.Diagnostics.PerformanceCounterLib.CreateRegistryEntry(String categoryName, PerformanceCounterCategoryType categoryType, CounterCreationDataCollec tion creationData, Boolean& iniRegistered) at System.Diagnostics.PerformanceCounterLib.RegisterCategory(String category Name, PerformanceCounterCategoryType categoryType, String categoryHelp, Counter CreationDataCollection creationData) at System.Diagnostics.PerformanceCounterCategory.Create(String categoryName, String categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData) at Microsoft.AspNet.SignalR.Utils.PerformanceCounterInstaller.InstallCounters()

   at Microsoft.AspNet.SignalR.Utils.InstallPerformanceCountersCommand.Execute(
String[] args)
   at Microsoft.AspNet.SignalR.Utils.Program.Main(String[] args)
The Zone of the assembly that failed was:
MyComputer
like image 38
CJBS Avatar answered Oct 05 '22 00:10

CJBS


Please note that if you follow the (correct) advice mentioned above and invoke 'signalr ipc' to install SignalR's custom counters, your application might inexplicably stop working altogether when running with the debugger. The issue is a bug in how the CLR deals with CultureInfo upon initialization. The problem exists at least in SignalR 2.2.0. The full explanation, and a couple of workarounds are discussed here: https://github.com/SignalR/SignalR/issues/3414

like image 42
Steve Faiwiszewski Avatar answered Oct 04 '22 23:10

Steve Faiwiszewski