Changing IIS 6/7 Application Pool settings programmatically

You can solve the problem using appcmd.exe. Where "DefaultAppPool" is the name of the pool.

appcmd list apppool /xml "DefaultAppPool" | appcmd set apppool /in /enable32BitAppOnWin64:true

If you have any troubles with running it using C# take a look How To: Execute command line in C#.

ps: Additional information about appcmd.exe you can find here. Default location of the tool is C:\windows\system32\inetsrv