未能從程式集“System.ServiceModel”中載入型別“System.ServiceModel.Activation.HttpModule”。

衣舞晨風發表於2015-11-26

作者:jiankunking 出處:http://blog.csdn.net/jiankunking


在Windows Server 2008中的IIS伺服器中部署WCF服務程式時,通過瀏覽器訪問報出如下錯誤:

“/TestService”應用程式中的伺服器錯誤。
未能從程式集“System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”中載入型別“System.ServiceModel.Activation.HttpModule”。
說明: 執行當前 Web 請求期間,出現未經處理的異常。請檢查堆疊跟蹤資訊,以瞭解有關該錯誤以及程式碼中導致錯誤的出處的詳細資訊。 
異常詳細資訊: System.TypeLoadException: 未能從程式集“System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”中載入型別“System.ServiceModel.Activation.HttpModule”。
源錯誤: 
執行當前 Web 請求期間生成了未經處理的異常。可以使用下面的異常堆疊跟蹤資訊確定有關異常原因和發生位置的資訊。
堆疊跟蹤: 
[TypeLoadException: 未能從程式集“System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”中載入型別“System.ServiceModel.Activation.HttpModule”。]
   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.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +63
   System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +124
   System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +76

[ConfigurationErrorsException: 未能從程式集“System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”中載入型別“System.ServiceModel.Activation.HttpModule”。]
   System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +12788096
   System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +69
   System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +66
   System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +300
   System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1262
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +133
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +304
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +404
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +475

[HttpException (0x80004005): 未能從程式集“System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”中載入型別“System.ServiceModel.Activation.HttpModule”。]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12981028
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12820621

版本資訊: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.34280

原因:

這是因為先安裝了 .NET Framework 4,隨後啟用了 .NET Framework 3.5 WCF HTTP 啟用,則會發生此錯誤。

解決辦法:

微軟官方對該問題也作了解答:http://msdn.microsoft.com/zh-cn/library/aa751852.aspx

只需要已管理員使用者在cmd中執行aspnet_regiis.exe -i即可。

C:/WINDOWS/Microsoft.NET/Framework/v4.0.30319/aspnet_regiis.exe -i




相關文章