Microsoft MVP성태의 닷넷 이야기
글쓴 사람
정성태 (techsharer at outlook.com)
홈페이지
첨부 파일
 

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

심증은 있는데 물증이 없군요. ^^ 시기적으로 대규모 업데이트는 Visual Studio 2013 Update 3 적용 후라서 그 때문이라고 생각은 하는데 검색해 보면 Update 3와 무관한 글들이 있는 걸로 봐서 다른 원인도 있지 않을까 싶습니다.

암튼, 다음의 코드에서

SqlConnection connection = new SqlConnection()

이런 예외가 발생했습니다.

System.InvalidOperationException occurred
  HResult=-2146233079
  Message=The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly.
  Source=System
  StackTrace:
       at System.Diagnostics.PerformanceCounter.InitializeImpl()
  InnerException: 

    System.dll!System.Diagnostics.PerformanceCounter.InitializeImpl() + 0x610 bytes 
    System.dll!System.Diagnostics.PerformanceCounter.Initialize() + 0x39 bytes  
    System.dll!System.Diagnostics.PerformanceCounter.RawValue.set(long value = 0) + 0x3d bytes  
    System.Data.dll!System.Data.ProviderBase.DbConnectionPoolCounters.Counter.Counter(string categoryName = ".NET Data Provider for SqlServer", string instanceName = "_LM_W3SVC_59_ROOT-1-130518528898119[13428]", string counterName = "HardConnectsPerSecond", System.Diagnostics.PerformanceCounterType counterType = RateOfCountsPerSecond32) + 0xec bytes  
    System.Data.dll!System.Data.ProviderBase.DbConnectionPoolCounters.DbConnectionPoolCounters(string categoryName = ".NET Data Provider for SqlServer", string categoryHelp = "Counters for System.Data.SqlClient") + 0x1fd bytes  
    ...[생략]...
    System.Web.dll!System.Web.Hosting.PipelineRuntime.ProcessRequestNotification(System.IntPtr rootedObjectsPointer = 0, System.IntPtr nativeRequestContext = 242157700, System.IntPtr moduleData = 12, int flags = 68) + 0x48 bytes    
    [Appdomain Transition]  

그러고 보니, 최근에 성능 카운터 관련해서 유사한 문제가 있었죠.

SignalR 오류 메시지 - Counter 'Messages Bus Messages Published Total' does not exist in the specified Category.
; https://www.sysnet.pe.kr/2/0/1727

일단 현재의 문제는 SqlConnection 객체 생성 시에 ".NET Data Provider for SqlServer" 범주의 "HardConnectsPerSecond" 성능 카운터가 없다는 것인데 이번에도 perfmon.msc를 이용해 확인해 보면 정말로 해당 카운터가 목록에 나타나지 않습니다.

검색해 보면, 닷넷 관련 성능 카운터를 다시 등록하라고 나오면서 아래의 명령어가 나오는데요.

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

아쉽게도 위의 성능 카운터 등록은 이번 경우에는 해당하지 않습니다. 왜냐하면, corperfmonsymbols.ini에는 ".NET CLR "로 시작하는 성능 카운터만 정의되어 있을 뿐 ".NET Data Provider for SqlServer", ".NET Data Provider for Oracle" 범주는 별도로 존재하기 때문입니다. 등록된 성능 카운터 ini 파일들을 뒤져보면 각각 다음의 경로에 있는 것을 확인할 수 있습니다.

C:\Windows\Inf\.NET Data Provider for Oracle\_DataOracleClientPerfCounters_shared12_neutral.ini
C:\Windows\Inf\.NET Data Provider for SqlServer\_dataperfcounters_shared12_neutral.ini

그래서, 다음과 같이 등록해 주시면 됩니다. ^^

C:\Windows\Inf\.NETFramework>cd  C:\Windows\Inf\.NET Data Provider for SqlServer

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

C:\Windows\Inf\.NET Data Provider for SqlServer>cd C:\Windows\Inf\.NET Data Provider for Oracle

C:\Windows\Inf\.NET Data Provider for Oracle>lodctr _DataOracleClientPerfCounters_shared12_neutral.ini




참고로 해제는 "unlodctr [drivername]"이라고 명령어를 실행하면 되는데요. 이 때 "[drivername]"은 해당 ini 파일에서 얻을 수 있습니다. 예를 들어, C:\Windows\Inf\.NETFramework\corperfmonsymbols.ini 파일을 메모장으로 열어 보면,

[info]
drivername=.NETFramework
symbolfile=CORPerfMonSymbols.h

이렇게 닷넷 성능 카운터의 drivername이 ".NETFramework"이기 때문에 아래의 명령어를 이용해 등록을 해제할 수 있습니다.

C:\Windows\Inf\.NETFramework>unlodctr .NETFramework

Removing counter names and explain text for .NETFramework
Updating text for language 009




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]







[최초 등록일: ]
[최종 수정일: 8/11/2014]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




1  2  3  4  5  6  7  8  9  10  11  12  13  14  [15]  ...
NoWriterDateCnt.TitleFile(s)
13255정성태2/10/20234518오류 유형: 845. gihub - windows2022 이미지에서 .NET Framework 4.5.2 미만의 프로젝트에 대한 빌드 오류
13254정성태2/10/20234402Windows: 223. (WMI 쿼리를 위한) PowerShell 문자열 escape 처리
13253정성태2/9/20235179Windows: 222. C# - 다른 윈도우 프로그램이 실행되었음을 인식하는 방법파일 다운로드1
13252정성태2/9/20234004오류 유형: 844. ssh로 명령어 수행 시 멈춤 현상
13251정성태2/8/20234458스크립트: 44. 파이썬의 3가지 스레드 ID
13250정성태2/8/20236277오류 유형: 843. System.InvalidOperationException - Unable to configure HTTPS endpoint
13249정성태2/7/20235121오류 유형: 842. 리눅스 - You must wait longer to change your password
13248정성태2/7/20234170오류 유형: 841. 리눅스 - [사용자 계정] is not in the sudoers file. This incident will be reported.
13247정성태2/7/20235071VS.NET IDE: 180. Visual Studio - 닷넷 소스 코드 디버깅 중 "Decompile source code"가 동작하는 않는 문제
13246정성태2/6/20234199개발 환경 구성: 664. Hyper-V에 설치한 리눅스 VM의 VHD 크기 늘리는 방법 - 두 번째 이야기
13245정성태2/6/20234770.NET Framework: 2093. C# - PEM 파일을 이용한 RSA 개인키/공개키 설정 방법파일 다운로드1
13244정성태2/5/20234127VS.NET IDE: 179. Visual Studio - External Tools에 Shell 내장 명령어 등록
13243정성태2/5/20234976디버깅 기술: 190. windbg - Win32 API 호출 시점에 BP 거는 방법 [1]
13242정성태2/4/20234420디버깅 기술: 189. ASP.NET Web Application (.NET Framework) 프로젝트의 숨겨진 예외 - System.UnauthorizedAccessException
13241정성태2/3/20233920디버깅 기술: 188. ASP.NET Web Application (.NET Framework) 프로젝트의 숨겨진 예외 - System.IO.FileNotFoundException
13240정성태2/1/20234076디버깅 기술: 187. ASP.NET Web Application (.NET Framework) 프로젝트의 숨겨진 예외 - System.Web.HttpException
13239정성태2/1/20233738디버깅 기술: 186. C# - CacheDependency의 숨겨진 예외 - System.Web.HttpException
13238정성태1/31/20235821.NET Framework: 2092. IIS 웹 사이트를 TLS 1.2 또는 TLS 1.3 프로토콜로만 운영하는 방법
13237정성태1/30/20235480.NET Framework: 2091. C# - 웹 사이트가 어떤 버전의 TLS/SSL을 지원하는지 확인하는 방법
13236정성태1/29/20235090개발 환경 구성: 663. openssl을 이용해 인트라넷 IIS 사이트의 SSL 인증서 생성
13235정성태1/29/20234647개발 환경 구성: 662. openssl - 윈도우 환경의 명령행에서 SAN 적용하는 방법
13234정성태1/28/20235729개발 환경 구성: 661. dnSpy를 이용해 소스 코드가 없는 .NET 어셈블리의 코드를 변경하는 방법 [1]
13233정성태1/28/20237057오류 유형: 840. C# - WebClient로 https 호출 시 "The request was aborted: Could not create SSL/TLS secure channel" 예외 발생
13232정성태1/27/20234808스크립트: 43. uwsgi의 --processes와 --threads 옵션
13231정성태1/27/20233736오류 유형: 839. python - TypeError: '...' object is not callable
13230정성태1/26/20234105개발 환경 구성: 660. WSL 2 내부로부터 호스트 측의 네트워크로 UDP 데이터가 1개의 패킷으로만 제한되는 문제
1  2  3  4  5  6  7  8  9  10  11  12  13  14  [15]  ...