new SqlConnection - The requested Performance Counter is not a custom counter

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

This error suddenly started happening today when debugging in Visual Studio 2015, why I don´t know. But it seems the counter related to the connection pool disappeared from my Windows machine.

It occurred inside the constructor of SqlConnection. After much searching the following fixed it for me:

cd C:\Windows\Inf\.NET Data Provider for SqlServer lodctr _dataperfcounters_shared12_neutral.ini

Make sure you run in a command window As Administrator.