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

ICOMAdminCatalog::GetCollection에서 CO_E_ISOLEVELMISMATCH(0x8004E02F) 오류 발생

제가 만든 코드에서 다음과 같이 COM+ Admin 객체를 사용합니다.

HRESULT hr = ::CoCreateInstance(CLSID_COMAdminCatalog, NULL, CLSCTX_INPROC_SERVER, IID_IUnknown, (LPVOID *)&pUnknown);
if (hr != S_OK)
{
    break;
}

CComQIPtr<ICOMAdminCatalog> pComAdminCatalog = pUnknown;
if (pComAdminCatalog == NULL)
{
    break;
}

CComPtr<ICatalogCollection> pAppColl = NULL;
CComBSTR ApplicationName = Value_Applications;
hr = pComAdminCatalog->GetCollection(ApplicationName, (IDispatch **)&pAppColl);

그런데 특정 COM+ 객체에서 저 코드가 호출되는 경우 hr 반환값이 0x8004E02F로 나옵니다. 이 오류 코드의 의미는,

0x8004E02F (CO_E_ISOLEVELMISMATCH)

Failed to get ICatalogCollection
The TxIsolation Level property for the COM+ component being created is stronger than the TxIsolationLevel for the "root" component for the transaction. The creation failed.


이렇다고 하는데... 흠~~~ ^^;

일단, 이론적으로 문제 분석을 해보겠습니다. 재현 코드를 만들어 보는 것이 좋겠지요? ^^ TxIsolation 레벨에 따라 이런 오류가 발생하려면 COM+ 객체가 2개 있어야 합니다. 그중에서 첫 번째 활성화되는 (A라고 하는) COM+ 객체가 트랜잭션에 대한 '문맥(context)'을 생성합니다. 그리고, 그 트랜잭션을 따르는 (B라고 하는) COM+ 객체가 TxIsolationLevel을 A 객체가 생성한 문맥보다 더 높은 안정성을 요구해야 합니다.

일례로 다음과 같은 문맥 설정이 됩니다.

A COM+: TransactionOption.Required, TransactionIsolationLevel.ReadCommitted
B COM+: TransactionOption.Required, TransactionIsolationLevel.Serializable

또는 이런 식입니다.

A COM+: TransactionOption.Required, TransactionIsolationLevel.ReadCommitted
B COM+: TransactionOption.Supported, TransactionIsolationLevel.Serializable

이런 설정으로 구성된 경우, A COM+의 메서드 내에서 B COM+의 메서드를 호출하면 CO_E_ISOLEVELMISMATCH 오류가 발생합니다.

반면 다음과 같은 식에서는 문제가 없습니다. (테스트는 안 해봤습니다. 아마도! ^^)

A COM+: TransactionOption.Disabled, TransactionIsolationLevel.ReadCommitted
B COM+: TransactionOption.Required, TransactionIsolationLevel.Serializable

A COM+: TransactionOption.NotSupported, TransactionIsolationLevel.ReadCommitted
B COM+: TransactionOption.Required, TransactionIsolationLevel.Serializable

A COM+: TransactionOption.Required, TransactionIsolationLevel.ReadCommitted
B COM+: TransactionOption.RequiresNew, TransactionIsolationLevel.Serializable

왜냐하면, A COM+ 객체가 생성한 문맥의 트랜잭션 환경을 B COM+ 객체에서 따르지 않기 때문에 TransactionIsolationLevel의 영향이 없습니다.




그런데, 재미있는 것은 제 경우에 COM+ 메서드 내에서 활성화되긴 하지만 제가 활성화하려는 ICOMAdminCatalog는 COM+에 직접적으로 등록되어 있지 않기 때문에 위의 상황과 별개로 보입니다. 그래서 좀 혼란스러웠는데요, 다행히 다음의 문서에서 문제의 원인을 찾을 수 있었습니다.

Accessing the COM+ Catalog
; https://docs.microsoft.com/en-us/windows/win32/cossdk/accessing-the-com--catalog

When you initiate programmatic administration by instantiating a COMAdminCatalog object, this object opens a session with the local catalog server. Requests for collections or collection items on the local catalog are handled by the local catalog server. When you connect to a remote machine, you are communicating with the catalog server on that machine.


즉, COMAdminCatalog는 내부적으로 "the local catalog server"를 이용하고 있으며 이것은 "COM+ Applications"에서 늘 활성화되어 있는 "System Application"의 "Catsrv.CatalogServer"를 지칭하는 것으로 보입니다. 예상할 수 있듯이, 이는 Serializable로 되어 있습니다.

complus_getcatalog_error_0.png

실제로 이 코드가 문제를 일으키는지 테스트를 해봐야 할 텐데요. 이를 위해 예전에 만들어 두었던 COM+를,

관리자 권한이 필요한 작업을 COM+에 대행
; https://www.sysnet.pe.kr/2/0/1290

문제가 되었던 COM+ 객체의 환경처럼 TransactionIsolationLevel을 ReadCommitted로 설정한 후,

complus_getcatalog_error_1.png

테스트해보면 정확히 ICOMAdminCatalog::GetCollection 호출에서 "0x8004E02F (CO_E_ISOLEVELMISMATCH)" 예외가 발생합니다.

(첨부 파일은 ReadCommitted로 설정된 COM+ 예제 코드를 포함합니다.)



[2016-12-19 추가] 제가 요즘 정신이 없군요. ^^; 위의 글에 대한 우회 해결책을 적는다는 것을 깜빡했습니다.

위와 같은 상황에서 Catalog 객체를 정상적으로 접근하고 싶다면 해당 코드 자체를 별도의 스레드 위에서 실행하면 됩니다. 대충 이런 식으로. ^^

std::thread t([&]()
{
    CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
    
    // ... Catalog 코드

    CoUninitialize();
});

t.join();




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







[최초 등록일: ]
[최종 수정일: 6/11/2021]

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

비밀번호

댓글 작성자
 




... 61  62  63  64  65  66  67  [68]  69  70  71  72  73  74  75  ...
NoWriterDateCnt.TitleFile(s)
11930정성태6/5/201912203.NET Framework: 842. .NET Reflection을 대체할 System.Reflection.Metadata 소개 [1]
11929정성태6/5/201911981.NET Framework: 841. Windows Forms/C# - 클립보드에 RTF 텍스트를 복사 및 확인하는 방법 [1]
11928정성태6/5/201910610오류 유형: 543. PowerShell 확장 설치 시 "Catalog file '[...].cat' is not found in the contents of the module" 오류 발생
11927정성태6/5/201911590스크립트: 15. PowerShell ISE의 스크립트를 복사 후 PPT/Word에 붙여 넣으면 한글이 깨지는 문제 [1]
11926정성태6/4/201913098오류 유형: 542. Visual Studio - pointer to incomplete class type is not allowed
11925정성태6/4/201911838VC++: 131. Visual C++ - uuid 확장 속성과 __uuidof 확장 연산자파일 다운로드1
11924정성태5/30/201913641Math: 57. C# - 해석학적 방법을 이용한 최소 자승법 [1]파일 다운로드1
11923정성태5/30/201913260Math: 56. C# - 그래프 그리기로 알아보는 경사 하강법의 최소/최댓값 구하기파일 다운로드1
11922정성태5/29/201911371.NET Framework: 840. ML.NET 데이터 정규화파일 다운로드1
11921정성태5/28/201916265Math: 55. C# - 다항식을 위한 최소 자승법(Least Squares Method)파일 다운로드1
11920정성태5/28/20199933.NET Framework: 839. C# - PLplot 색상 제어
11919정성태5/27/201913007Math: 54. C# - 최소 자승법의 1차 함수에 대한 매개변수를 단순 for 문으로 구하는 방법 [1]파일 다운로드1
11918정성태5/25/201914174Math: 53. C# - 행렬식을 이용한 최소 자승법(LSM: Least Square Method)파일 다운로드1
11917정성태5/24/201914251Math: 52. MathNet을 이용한 간단한 통계 정보 처리 - 분산/표준편차파일 다운로드1
11916정성태5/24/201912278Math: 51. MathNET + OxyPlot을 이용한 간단한 통계 정보 처리 - Histogram파일 다운로드1
11915정성태5/24/201914584Linux: 11. 리눅스의 환경 변수 관련 함수 정리 - putenv, setenv, unsetenv
11914정성태5/24/201914289Linux: 10. 윈도우의 GetTickCount와 리눅스의 clock_gettime파일 다운로드1
11913정성태5/23/201911951.NET Framework: 838. C# - 숫자형 타입의 bit(2진) 문자열, 16진수 문자열 구하는 방법파일 다운로드1
11912정성태5/23/201911603VS.NET IDE: 137. Visual Studio 2019 버전 16.1부터 리눅스 C/C++ 프로젝트에 추가된 WSL 지원
11911정성태5/23/201910714VS.NET IDE: 136. Visual Studio 2019 - 리눅스 C/C++ 프로젝트에 인텔리센스가 동작하지 않는 경우
11910정성태5/23/201919316Math: 50. C# - MathNet.Numerics의 Matrix(행렬) 연산 [1]파일 다운로드1
11909정성태5/22/201913762.NET Framework: 837. C# - PLplot 사용 예제 [1]파일 다운로드1
11908정성태5/22/201912083.NET Framework: 836. C# - Python range 함수 구현파일 다운로드1
11907정성태5/22/20199910오류 유형: 541. msbuild - MSB4024 The imported project file "...targets" could not be loaded
11906정성태5/21/20199863.NET Framework: 835. .NET Core/C# - 리눅스 syslog에 로그 남기는 방법
11905정성태5/21/201910508.NET Framework: 834. C# - 폴더 경로 문자열에서 "..", "." 표기를 고려한 최종 문자열을 얻는 방법 - 두 번째 이야기
... 61  62  63  64  65  66  67  [68]  69  70  71  72  73  74  75  ...