닷넷 COM+ - Failed to load the runtime.
닷넷 COM+ 사용 시 다음과 같은 오류가 발생한다면?
Server Error in '/' Application.
--------------------------------------------------------------------------------
Failed to load the runtime. (Exception from HRESULT: 0x80131700)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException: Failed to load the runtime. (Exception from HRESULT: 0x80131700)
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[COMException (0x80131700): Failed to load the runtime. (Exception from HRESULT: 0x80131700)]
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) +0
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) +16
System.EnterpriseServices.Thunk.Proxy.CoCreateObject(Type serverType, Boolean bQuerySCInfo, Boolean& bIsAnotherProcess, String& uri) +301
System.EnterpriseServices.ServicedComponentProxyAttribute.CreateInstance(Type serverType) +195
System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj) +85
WebSiteTest.ComPlusServerTest.Page_Load(Object sender, EventArgs e) in d:\WebSiteTest4\ComPlusServerTest.aspx.cs:115
System.Web.UI.Control.OnLoad(EventArgs e) +104
System.Web.UI.Control.LoadRecursive() +112
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2213
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.2623.0
만약 COM+가 "서버 활성화" 유형이고 해당 DLL이 CLR 2 기반으로 빌드된 것이라면 저런 오류가 발생할 수 있습니다. 일례로, COM+의 dllhost.exe에서 DLL을 활성화시킬 때 DLL의 Target Framework 버전이 2.0 ~ 3.5라면 dllhost.exe 내에 .NET Framework 2.0 ~ 3.5에 해당하는 런타임을 올리려 할 것입니다. 문제는, 해당 운영체제에 .NET 3.5가 설치되어 있지 않은 경우 저런 식으로 "Failed to load the runtime" 예외가 발생하는 것입니다.
문제의 원인을 알았으니 해결도 간단합니다.
그냥 .NET Framework 3.5를 설치하든가, 해당 COM+ DLL을 .NET Framework 4.0 이상의 버전으로 다시 빌드해 배포하면 됩니다.
[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]