HttpModule not run and IIS manager cannot recogonize the type

cst_zf 11 Reputation points
2021-08-21T19:23:52.513+00:00

I compile a http module named MyHttpModule.dll with a class MyHttpLogger inherited from IHttpModule, target to .net Framework 4.

"\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\x64\gacutil.exe" /i MyHttpModule.dll //run successfully.

I can see the dll in C:\Windows\Microsoft.NET\assembly\GAC_MSIL\LyxonHttpModule\v4.0_1.0.0.0__5d332fce66d3892e with correct file size and last modified time.

When I try to add managed module in IIS manager of Win10, it report ----- The specified type does not exist in the Global Assembly Cache (GAC). Please install the associated assembly into the GAC.

I can add this http module by appcmd but it seem not be loaded by IIS.

What should I do now?

Internet Information Services
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce Zhang-MSFT 3,751 Reputation points
    2021-08-23T07:42:38.227+00:00

    Hi @ChiSongTao-1785 ,

    I notice that you add the dll in .NET4.0. If you use gacutil to install the assembly to the GAC, it will in .net GAC folder(%windir%\Microsoft.NET\assembly\GAC_MSIL). But it cannot be available in the "add managed module" dropdown in IIS manager. Only assembly in windows GAC folder(%windir%\assembly) can show and gacutil will tell you that assembly is installed correctly in GAC.

    Another point is there are two GAC folder.

    Microsoft.NET for .net 4.0 and Windows GAC for pre .net 4.0.
    If you create assembly in .net3.5 or older, it will installed in windows GAC and can be available in the type dropdown, IIS manager.
    If you create assembly in .net4.0, it will installed in Microsoft.NET GAC and not available in the type dropdown.

    So the .NET4.0 assembly cannot add by IIS manager. The only way is add it in applicationHost.config manually. The correct process is:

    1. Create .NET4.0 class library and compile it.
    2. Install it in the .NET4.0 GAC by using gacutil. ( You have done it.)
    3. Add this line under <modules> in the applicationHost.config: <add name="MyName" type="NameSpace.ClassName" preCondition="managedHandler,runtimeVersionv4.0" />

    This make the module run on the requests to sites developed in .net4.0. The requests to sites developed in pre .net4.0 cannot use a module created in .net4.0.


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Bruce Zhang

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.