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

비밀번호

댓글 작성자
 




... 121  122  [123]  124  125  126  127  128  129  130  131  132  133  134  135  ...
NoWriterDateCnt.TitleFile(s)
10848정성태9/8/201527331VS.NET IDE: 103. Visual Studio의 Ctrl + F5 실행 동작파일 다운로드1
10847정성태9/8/201523443VS.NET IDE: 102. 목록(List) 타입의 값을 디버깅 중 Watch 창에서 확인하는 방법 [1]파일 다운로드1
10846정성태9/8/201520811오류 유형: 306. "query user" 명령어에 공백 문자가 포함된 계정을 전달하는 경우
10845정성태9/3/201521893오류 유형: 305. 윈도우 백업 시 오류 - 0x80780166
10844정성태9/2/201523104.NET Framework: 528. C# - 상호 참조하는 경우의 정적 생성자 동작 방식 [4]파일 다운로드1
10843정성태9/1/201523802VS.NET IDE: 101. Visual Studio 2015의 솔루션 탐색기가 클래스 뷰 정보로 인해 느려지는 현상
10842정성태9/1/201520867.NET Framework: 527. 닷넷 사용자 정의 예외 클래스의 최소 구현 코드 - 세 번째 이야기
10841정성태8/31/201530183개발 환경 구성: 276. Visual Studio 2013에서 C# 6과 닷넷 4.6 기능을 사용하려면?
10839정성태8/22/201528766Windows: 112. 윈도우 10에서 터치 키보드를 안 뜨게 할 수 있는 방법 [4]
10838정성태8/22/201539054오류 유형: 304. Windows 10에서 VPN 연결이 실패한다면? [3]
10837정성태8/21/201519340오류 유형: 303. Your computer is low on memory. Save your files and close these programs...
10836정성태8/21/201520279오류 유형: 302. 설치 파일 실행 시 "This app can't run on your PC" 오류가 뜬다면?
10835정성태8/21/201528789웹: 31. Microsoft Edge 브라우저를 명령행에서 띄우는 방법 [1]
10834정성태8/19/201520878.NET Framework: 526. 닷넷 - 값 형식을 new 없이 생성하면 0으로 초기화되지 않는다?
10833정성태8/18/201525483.NET Framework: 525. C# - 닷넷에서 프로세스가 열고 있는 파일 목록을 구하는 방법파일 다운로드1
10832정성태8/17/201529905디버깅 기술: 74. x64 콜 스택 인자 추적과 windbg의 Child-SP, RetAddr, Args to Child 값 확인 [8]파일 다운로드2
10831정성태8/13/201529900.NET Framework: 524. .NET 4.0과 .NET 4.5의 컴파일 결과 차이점 [1]파일 다운로드1
10830정성태8/12/201523899개발 환경 구성: 275. Web.config이 적용되지 않는 프로젝트에서 Razor 템플릿 파일의 C# 컴파일러 버전 제어 [1]
10829정성태8/10/201525983개발 환경 구성: 274. PowerShell/명령행에서 JDK/JRE를 무인(unattended)/자동 설치를 하는 방법 [3]
10828정성태8/10/201531576웹: 30. Edge 브라우저에서 "이 웹 사이트에는 Internet Explorer가 필요함" 단계를 없애는 방법 [1]
10827정성태7/8/201532967개발 환경 구성: 273. Visual Studio 2015에서 Github와 연동하는 방법 [3]
10826정성태7/8/201522585오류 유형: 301. The trust relationship between this workstation and the primary domain failed. - 두 번째 이야기
10825정성태7/8/201522154개발 환경 구성: 272. Visual Studio IDE 설치 없이 Visual Studio SDK 설치하는 방법
10824정성태7/7/201527323개발 환경 구성: 271. Team Foundation Server 2015 설치 방법 [1]
10823정성태7/7/201527896오류 유형: 300. SqlException (0x80131904): Unable to open the physical file
10822정성태7/7/201527257오류 유형: 299. The 'Visual C++ Project System Package' package did not load correctly.
... 121  122  [123]  124  125  126  127  128  129  130  131  132  133  134  135  ...