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

비밀번호

댓글 작성자
 




... 46  47  [48]  49  50  51  52  53  54  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
12422정성태11/21/20208680.NET Framework: 973. .NET 5, .NET Framework에서만 허용하는 UnmanagedCallersOnly 사용예파일 다운로드1
12421정성태11/19/20208427.NET Framework: 972. DNNE가 출력한 NE DLL을 직접 생성하는 방법파일 다운로드1
12420정성태11/19/20207631오류 유형: 684. Visual C++ - MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
12419정성태11/19/20208812VC++: 139. Visual C++ - .NET Core의 nethost.lib와 정적 링크파일 다운로드1
12418정성태11/19/202010900오류 유형: 683. Visual C++ - error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MDd_DynamicDebug'파일 다운로드1
12417정성태11/19/20208298오류 유형: 682. Visual C++ - warning LNK4099: PDB '...pdb' was not found with '...lib(pch.obj)' or at '...pdb'; linking object as if no debug info
12416정성태11/19/20209580오류 유형: 681. Visual C++ - error LNK2001: unresolved external symbol _CrtDbgReport
12415정성태11/18/20209583.NET Framework: 971. UnmanagedCallersOnly 특성과 DNNE 사용파일 다운로드1
12414정성태11/18/202010660VC++: 138. x64 빌드에서 extern "C"가 아닌 경우 ___cdecl name mangling 적용 [4]파일 다운로드1
12413정성태11/17/202010334.NET Framework: 970. .NET 5 / .NET Core - UnmanagedCallersOnly 특성을 사용한 함수 내보내기파일 다운로드1
12412정성태11/16/202012582.NET Framework: 969. .NET Framework 및 .NET 5 - UnmanagedCallersOnly 특성 사용파일 다운로드1
12411정성태11/12/20209573오류 유형: 680. C# 9.0 - Error CS8889 The target runtime doesn't support extensible or runtime-environment default calling conventions.
12410정성태11/12/20209566디버깅 기술: 174. windbg - System.TypeLoadException 예외 분석 사례
12409정성태11/12/202010951.NET Framework: 968. C# 9.0의 Function pointer를 이용한 함수 주소 구하는 방법파일 다운로드1
12408정성태11/9/202022147도서: 시작하세요! C# 9.0 프로그래밍 [8]
12407정성태11/9/202011207.NET Framework: 967. "clr!JIT_DbgIsJustMyCode" 호출이 뭘까요?
12406정성태11/8/202012757.NET Framework: 966. C# 9.0 - (15) 최상위 문(Top-level statements) [5]파일 다운로드1
12405정성태11/8/202010271.NET Framework: 965. C# 9.0 - (14) 부분 메서드에 대한 새로운 기능(New features for partial methods)파일 다운로드1
12404정성태11/7/202010735.NET Framework: 964. C# 9.0 - (13) 모듈 이니셜라이저(Module initializers)파일 다운로드1
12403정성태11/7/202010808.NET Framework: 963. C# 9.0 - (12) foreach 루프에 대한 GetEnumerator 확장 메서드 지원(Extension GetEnumerator)파일 다운로드1
12402정성태11/7/202011399.NET Framework: 962. C# 9.0 - (11) 공변 반환 형식(Covariant return types) [1]파일 다운로드1
12401정성태11/5/202010303VS.NET IDE: 153. 닷넷 응용 프로그램에서의 "My Code" 범위와 "Enable Just My Code"의 역할 [1]
12400정성태11/5/20207394오류 유형: 679. Visual Studio - "Source Not Found" 창에 "Decompile source code" 링크가 없는 경우
12399정성태11/5/202010990.NET Framework: 961. C# 9.0 - (10) 대상으로 형식화된 조건식(Target-typed conditional expressions)파일 다운로드1
12398정성태11/4/20209469오류 유형: 678. Windows Server 2008 R2 환경에서 Powershell을 psexec로 원격 실행할 때 hang이 발생하는 문제
12397정성태11/4/20209576.NET Framework: 960. C# - 조건 연산자(?:)를 사용하는 경우 달라지는 메서드 선택 사례파일 다운로드1
... 46  47  [48]  49  50  51  52  53  54  55  56  57  58  59  60  ...