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

WCF - The protocol 'net.tcp' does not have an implementation of HostedTransportConfiguration type registered.

Windows Server 2008에 있던 WCF 서비스를 Windows Server 2012로 옮겨 왔는데, 최초 WCF 서비스를 호출할 때 이런 오류가 발생합니다.

Server Error in '/WCFs' Application.
The protocol 'net.tcp' does not have an implementation of HostedTransportConfiguration type registered.
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.InvalidOperationException: The protocol 'net.tcp' does not have an implementation of HostedTransportConfiguration type registered.

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:

[InvalidOperationException: The protocol 'net.tcp' does not have an implementation of HostedTransportConfiguration type registered.]
   System.ServiceModel.AsyncResult.End(IAsyncResult result) +396
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +196
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +222
   System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +211
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +131
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +76

Version Information: Microsoft .NET Framework Version:2.0.50727.8810; ASP.NET Version:2.0.50727.8762

그런 다음, 두 번째 WCF 서비스를 호출할 때는 오류 메시지가 다음과 같이 바뀝니다.

Server Error in '/WCFs' Application.
An item with the same key has already been added.
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.ArgumentException: An item with the same key has already been added.

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:

[ArgumentException: An item with the same key has already been added.]
   System.ServiceModel.AsyncResult.End(IAsyncResult result) +396
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +196
   System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, Boolean flowContext) +222
   System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +211
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +131
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +76

Version Information: Microsoft .NET Framework Version:2.0.50727.8810; ASP.NET Version:2.0.50727.8762

다행히 검색했더니, 정확히 그런 이유로 인한 KB 자료가 있습니다. ^^;

"'Net.tcp' does not have an implementation of HostedTransportConfiguration type registered" error message when you host .NET Framework 3.5 WCF service on Windows Server 2012 or Windows 8
; https://support.microsoft.com/ko-kr/help/2803161/net-tcp-does-not-have-an-implementation-of-hostedtransportconfiguratio

따라서 다음과 같이 관리자 권한의 명령행으로 실행시켜 주면 되는데,

"%windir%\Microsoft.NET\Framework64\v3.0\Windows Communication Foundation\SMConfigInstaller.exe" -c:install -f:tcp -f:pipe -f:msmq -f:http
"%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\SMConfigInstaller.exe" -c:install -f:tcp -f:pipe -f:msmq -f:http

이로 인해 아래 2개의 web.config 파일에,

%windir%\Microsoft.NET\Framework64\v2.0.50727\CONFIG\web.config
%windir%\Microsoft.NET\Framework\v2.0.50727\CONFIG\web.config

system.web/protocols, system.serviceModel/serviceHostingEnvironment 노드의 하위로 binding 프로토콜 관련 항목이 추가되고,

<configuration>
    ...[생략]...
    <system.web>
        ...[생략]...

        <protocols>
            <add name="net.tcp" processHandlerType="System.ServiceModel.WasHosting.TcpProcessProtocolHandler, System.ServiceModel.WasHosting, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" appDomainHandlerType="System.ServiceModel.WasHosting.TcpAppDomainProtocolHandler, System.ServiceModel.WasHosting, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false" />
            <add name="net.pipe" processHandlerType="System.ServiceModel.WasHosting.NamedPipeProcessProtocolHandler, System.ServiceModel.WasHosting, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" appDomainHandlerType="System.ServiceModel.WasHosting.NamedPipeAppDomainProtocolHandler, System.ServiceModel.WasHosting, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false" />
            <add name="net.msmq" processHandlerType="System.ServiceModel.WasHosting.MsmqProcessProtocolHandler, System.ServiceModel.WasHosting, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" appDomainHandlerType="System.ServiceModel.WasHosting.MsmqAppDomainProtocolHandler, System.ServiceModel.WasHosting, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false" />
            <add name="msmq.formatname" processHandlerType="System.ServiceModel.WasHosting.MsmqIntegrationProcessProtocolHandler, System.ServiceModel.WasHosting, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" appDomainHandlerType="System.ServiceModel.WasHosting.MsmqIntegrationAppDomainProtocolHandler, System.ServiceModel.WasHosting, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" validate="false" />
        </protocols>

        ...[생략]...
    </system.web>

    <system.serviceModel>
        <serviceHostingEnvironment>
            <add name="net.tcp" transportConfigurationType="System.ServiceModel.Activation.TcpHostedTransportConfiguration, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            <add name="net.pipe" transportConfigurationType="System.ServiceModel.Activation.NamedPipeHostedTransportConfiguration, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            <add name="net.msmq" transportConfigurationType="System.ServiceModel.Activation.MsmqHostedTransportConfiguration, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
            <add name="msmq.formatname" transportConfigurationType="System.ServiceModel.Activation.MsmqIntegrationHostedTransportConfiguration, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
        </serviceHostingEnvironment>
    </system.serviceModel>
</configuration>

%windir%\system32\inetsrv\config\applicationHost.config 파일에도 configuration/location/system.webServer/modules에 ServiceModel 항목이 추가됩니다.

<configuration>
    ...[생략]...
    <location path="" overrideMode="Allow">
        ...[생략]...

        <system.webServer>
            ...[생략]...
            <modules>
                    ...[생략]...
                    <add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="managedHandler" />
                    ...[생략]...
            </modules>

            <handlers accessPolicy="Read, Script">
                    ...[생략]...
                    <add name="svc-Integrated" path="*.svc" verb="*" type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" preCondition="integratedMode" />
                    ...[생략]...
            </handlers>

            ...[생략]...
        </system.webServer>

        ...[생략]...
    </location>

    ...[생략]...
</configuration>

SMConfigInstaller 호출로 인해 위와 같은 변경 사항이 포함되면 이후, .NET 3.5 WCF 사이트는 정상적으로 동작하게 됩니다.




이렇게 해서 .NET 3.5 WCF의 동작은 시켰지만, (바꾼 config 파일들이 전역 설정인 탓에) 그 여파로 인해 이번에는 같은 머신에 있던 .NET 4.0의 WCF 사이트가 다음과 같은 오류 메시지 등을 보이며 동작이 안 됩니다.

Server Error in '/' Application.
Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
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.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

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:

[TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +153
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName) +49
   System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +42
   System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +44
   System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +59
   System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +49

[ConfigurationErrorsException: Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
   System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +515
   System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, Boolean checkAptcaBit, Boolean ignoreCase) +36
   System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, Boolean checkAptcaBit) +20
   System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +60
   System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +84
   System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +207
   System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +948
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +148
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +176
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +204
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +213

[HttpException (0x80004005): Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +403
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +100
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +606

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0

Server Error in '/' Application.
Internal Server Error
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.ServiceModel.CommunicationException: Internal Server Error

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:

[CommunicationException: Internal Server Error]
   System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +240
   System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +876
   WcfInterfaceLib.IHelloWorld.GetDate(String year, String month, String day) +0
   Jennifer40.WebSiteTest.CallToAsmxService.Page_Load(Object sender, EventArgs e) in D:\workshop2\Jennifer\Sources\Agent\UnitTest\Jennifer40.WebSiteTest4\CallToAsmxService.aspx.cs:169
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +85
   System.Web.UI.Control.OnLoad(EventArgs e) +86
   System.Web.UI.Control.LoadRecursive() +97
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2056

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0

Server Error in '/' Application.
Could not load type 'System.ServiceModel.Activation.HttpHandler' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
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.TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpHandler' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

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:

[TypeLoadException: Could not load type 'System.ServiceModel.Activation.HttpHandler' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.]
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMarkHandle stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName, ObjectHandleOnStack type) +0
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) +153
   System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName) +49
   System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark) +42
   System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +44
   System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +59
   System.Web.Configuration.HandlerFactoryCache.GetTypeWithAssert(String type) +51
   System.Web.Configuration.HandlerFactoryCache.GetHandlerType(String type) +17
   System.Web.Configuration.HandlerFactoryCache.Create(String type) +10
   System.Web.Configuration.HandlerFactoryCache..ctor(String type) +33
   System.Web.HttpApplication.GetFactory(String type) +98
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +265
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +231
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +134

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0

위의 오류 내용을 정리하면,

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Could not load type 'System.ServiceModel.Activation.HttpHandler' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

SMConfigInstaller가 %windir%\system32\inetsrv\config\applicationHost.config에 추가한 3.0.0.0 버전의 System.ServiceModel 참조로 인해, .NET 4.0 WCF 환경에서 해당 버전들의 어셈블리를 로드하지 못해 발생하는 것입니다. 이 문제를 해결하려면, 각각의 설정에 대해 preCondition에 "runtimeVersionv2.0"을 추가하면 됩니다.

<configuration>
    ...[생략]...
    <location path="" overrideMode="Allow">
        ...[생략]...

        <system.webServer>
            ...[생략]...
            <modules>
                    ...[생략]...
                    <add name="ServiceModel" 
                        type="System.ServiceModel.Activation.HttpModule, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
                            preCondition="managedHandler,runtimeVersionv2.0" />
                    ...[생략]...
            </modules>

            <handlers accessPolicy="Read, Script">
                    ...[생략]...
                    <add name="svc-Integrated" path="*.svc" verb="*" 
                        type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" 
                            preCondition="integratedMode,runtimeVersionv2.0" />
                    ...[생략]...
            </handlers>

            ...[생략]...
        </system.webServer>

        ...[생략]...
    </location>

    ...[생략]...
</configuration>

좀 더 자세한 사항은 다음의 KB 자료가 도움이 됩니다.

Error message after you install the .NET Framework 4.0: "Could not load type 'System.ServiceModel.Activation.HttpModule'"
; https://support.microsoft.com/en-us/help/2015129/error-message-after-you-install-the-net-framework-4-0-could-not-load-t




참고로, System.ServiceModel.Activation.HttpHandler로 인한 오류는 프로젝트에 포함한 web.config 내 serviceHostingEnvironment의 aspNetCompatibilityEnabled 값을 false로 주는 것으로도 해결할 수 있습니다. (물론, 이런 경우에는 해당 기능을 사용하지 않는 경우에만 가능할 텐데... 대부분의 경우 필요했으니까 설정했을 것이므로 저 옵션을 false로 변경하려면 소스 코드의 변경이 불가피할 것입니다.)

<serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true" />




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







[최초 등록일: ]
[최종 수정일: 8/5/2020]

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

비밀번호

댓글 작성자
 




... [181]  182  183  184  185  186  187  188  189  190  191  192  193  194  195  ...
NoWriterDateCnt.TitleFile(s)
493정성태5/26/200727106오류 유형: 34. Windows Server 2008 : CA 인증서 발급 실패
492정성태5/23/200726619.NET Framework: 89. ManagedThreadId - 두 번째 이야기 [5]파일 다운로드1
491정성태5/21/200726732.NET Framework: 88. ManagedThreadId ? [4]
490정성태5/19/200735233오류 유형: 33. error MSB6003: SxS DLL 로딩 오류 [2]
489정성태5/14/200723051.NET Framework: 87. .NET 2.0에서 C# 3.0 기능 사용하기
488정성태5/14/200721607Windows: 25. Multiple Input Queues
487정성태4/24/200727219VC++: 32. VC++에서 bool이 가지는 의미 [3]
486정성태3/22/200726244Windows: 24. DreamScene과 DWM(Desktop Window Manager)의 관계 [1]
485정성태3/17/200721566오류 유형: 32. VS.NET 2005 - x64 환경에서의 mixed 디버깅 환경 구성
484정성태3/17/200720730오류 유형: 31. SQL Compact Edition 설치 후 오류
483정성태3/17/200742131오류 유형: 30. x64 환경: .NET + COM 프로젝트 실행 시 오류 - 80040154 [2]
482정성태3/17/200731639Team Foundation Server: 17. 팀 프로젝트 접속 및 사용
481정성태3/17/200725553Team Foundation Server: 16. 팀 프로젝트 읽기 전용 사용자 등록
480정성태3/14/200723820.NET Framework: 86. GC(Garbage Collector)의 변화
479정성태3/14/200727664개발 환경 구성: 25. D820 - ReadyBoost 구동
478정성태3/14/200727101개발 환경 구성: 24. D820 고주파음 문제
477정성태3/14/200736365개발 환경 구성: 23. 비스타 x64 버전에서 서명되지 않은 드라이버 사용 [4]
476정성태3/9/200731844개발 환경 구성: 22. D820 노트북 - 설치 및 BitLocker 구성 [1]
475정성태3/6/200726213.NET Framework: 85. 공용 프로퍼티 자동 생성
474정성태3/5/200724460.NET Framework: 84. Lambda 표현식 응용 사례 [1]
473정성태3/4/200731492디버깅 기술: 14. TFS 오류 추적(TF53010, TF14105)
472정성태3/3/200730721디버깅 기술: 13. 예외 발생 시 Minidump 생성 - WinDBG [3]파일 다운로드1
471정성태3/1/200719805디버깅 기술: 12. Managed Method에 Break Point 걸기
469정성태2/28/200731394디버깅 기술: 11. (Managed) Main Method에 Break Point 걸기 [3]파일 다운로드1
470정성태3/1/200722820    답변글 디버깅 기술: 11.1. (Managed) Main Method에 Break Point 걸기 - 내용 보강
468정성태2/25/200732591COM 개체 관련: 20. 탭 브라우저의 윈도우 핸들 구하기 [3]
... [181]  182  183  184  185  186  187  188  189  190  191  192  193  194  195  ...