无法加载类型模块C#

对于Web应用程序和模块,我对VS非常陌生,

我试图运行/调试一个http模块,所以我遵循这个有用的教程:

https://dotnetcodr.com/2015/07/10/how-to-register-a-custom-http-module-in-your-net-web-application/

我在示例WebApplication中调试了他的测试模块。

现在我将模块链接到示例WebApplication中,我编辑了替换此Web.config的代码

  <add name="DescriptiveNameOfModule" type="HttpModuleTestApplication.Modules.TestModule"/>

与我的模块

  <add name="DescriptiveNameOfModule" type="MyHttpModule11.MyHttpModule"/>

但是当我运行它时,我得到一个包含以下错误的页面:

    [HttpException (0x80004005): Could not load type 'MyHttpModule11.MyHttpModule'.]
   System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase) +9972697
   System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +38

[ConfigurationErrorsException: Could not load type 'MyHttpModule11.MyHttpModule'.]
   System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase) +353
   System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, Boolean checkAptcaBit) +21
   System.Web.Configuration.Common.ModulesEntry.SecureGetType(String typeName, String propertyName, ConfigurationElement configElement) +39
   System.Web.Configuration.Common.ModulesEntry..ctor(String name, String typeName, String propertyName, ConfigurationElement configElement) +42
   System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +160
   System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1068
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +82
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +173
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

[HttpException (0x80004005): Could not load type 'MyHttpModule11.MyHttpModule'.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10085804
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254

可能是什么原因? 可能是由IIS不同版本引起的?


您可能需要包含此类型所在的程序集的名称。 例如。

<modules>
    <add name="DescriptiveNameOfModule" type="MyHttpModule11.MyHttpModule, AssemblyNameWithoutExtension"/>
</modules>
链接地址: http://www.djcxy.com/p/43803.html

上一篇: Could not load type module C#

下一篇: Request an action from httpModule