Is it possible to write an IIS Module in C++ that is compiled 32bit?

Smith, Roland 40 Reputation points
2024-02-08T21:49:27.43+00:00

I've created a Module in C++ which works well so far. The problem I have is that I'd like to have it be 32bit. I compile the DLL as 64-bit and it works fine. I compile as 32-bit and edit applicationHost.config and change preConditions to bitness32 or remove preConditions and it fails. Is it possible or am I missing something? Current entries in applicationHost.config (working 64-bit) that were added by IIS Manager:

<globalModules>
    <add name="TopwizWebModule" image="C:\source\repos\TopwizWebModule\x64\Release\TopwizWebModule.dll" preCondition="bitness64" />
</globalModules>

<handlers accessPolicy="Read, Execute, Script">
    <add name="TopwizWebModule" path="*.topwiz" verb="*" modules="TopwizWebModule" resourceType="File" preCondition="bitness64,winx86_64" />
</handlers>

<modules>
    <add name="TopwizWebModule" preCondition="bitness64" />
</modules> 
Internet Information Services
0 comments No comments
{count} votes

Accepted answer
  1. XuDong Peng-MSFT 10,341 Reputation points Microsoft Vendor
    2024-02-09T02:09:37.1766667+00:00

    Hi @Smith, Roland

    Is it possible or am I missing something?

    I think you may have forgotten to set Enable 32-Bit Application to True for the IIS application pool, so that the web application and the dll run at the same bitness.

    User's image

    Best regards,

    Xudong Peng


    If the answer is the right solution, please click "Accept Answer" and kindly upvote. If you have extra questions about this answer, please click "Comment".

    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.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Lex Li (Microsoft) 5,322 Reputation points Microsoft Employee
    2024-02-09T05:46:51.8333333+00:00

    First, you will have to prove that you did compile the code to a 32 bit library. Use a tool from Visual Studio command prompt like dumpbin to verify https://learn.microsoft.com/en-us/cpp/build/reference/dumpbin-command-line?view=msvc-170

    Second, I suggest you put 32-bit and 64-bit library files to IIS installation folders (32 bit in %windir%\sysWOW64\inetsrv and 64 bit in %windir%\system32\inetsrv and then registered in <globalModules> as <add name="TopwizWebModule" image="%windir%\System32\inetsrv\TopwizWebModule.dll" />.

    Finally, you can enable the module in your site/application by adding it to <modules> like <add name="TopwizWebModule" />.