I want to change Enable32BitAppOnWin64 property using C#. I know that the way of interacting with IIS 6 and IIS 7 are different. but I need the solution for both versions.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are a few differences in programmatically managing IIS 6 and IIS 7.
IIS 6 is programmatically managed using the
DirectoryEntryclass and the metabase database API.IIS 7 is managed using the
Microsoft.Web.Administrationassemblyand the
ServerManagerclass.Furthermore IIS 6 is not able to run both 64 bit and 32 bit worker processes
at the same time (see this MSDN BLOG).
So setting
Enable32BitAppOnWin64totruefor IIS 6 means that all workerprocesses (all application pools) are running as 32 bit processes.
IIS 7 is capable of running 64 bit and 32 bit worker processes at the same time.
This means that you set
Enable32BitAppOnWin64for a specific application pooland not for all application pools.
You also have to detect the version of IIS in order to use the correct API.
This can be done by reading the following DWORD values from the registry
(for more information see Learn IIS):
So, here is some code to set
Enable32BitAppOnWin64for IIS 6 and IIS 7(please note that you have to reference the
Microsoft.Web.Administrationand
System.DirectoryServicesassemblies in your Visual Studio project):I should also mention that there is a possibility to use the metabase API
for IIS 7, too. On Windows Server 2008 operating systems you can
install a role service called “IIS 6 Management Compatibility”. This
role service enables you to use the “old” IIS 6 API to manage IIS 7.
If “IIS 6 Management Compatibility” is an option for you change the
function
Enable32BitAppOnWin64IIS7as follows:Of course, then you do not have to reference the
Microsoft.Web.Administrationassembly.