Running IIS 7 In 32-bit Mode

I recently got a new machine at work with a 64-bit quad-core CPU, dual 15k RPM SCSI drives, 4G RAM, and, *gulp*, Vista. I’ve never used Vista before, and after all the horror stories I’ve heard, I was pretty hesitant. We’re using ASP.NET MVC with our new project, though, and deploying out to Windows Server 2008, which runs IIS7, so I figured developing with the same thing on my local box was a good idea. That means running the apps through IIS and not the built in Visual Studio 2008 Cassini server, which is what I was using back on XP.

So I set everything up, check out our project, fire up Visual Studio, hit debug, and BAM! I get a nice looking yellow screen of death, which, incidentally, isn’t our application’s start-up page. Here’s the exception it throws:

System.BadImageFormatException: Could not load file or assembly ‘OurProject.Core’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

WTF? It was working fine on my old box. I recompiled our app after changing all the projects to explicitly compile in 32-bit mode and still got the error. As it turns out, IIS will, by default, run in 64-bit mode on a 64-bit box. Makes sense. If you open Task Manager, you can see that’s how it works (note there’s no *32 next to the process name like all the other 32-bit apps that are running, like Fire Fox and Visual Studio):

Task Manager showing IIS 7 running in 64-bit mode.

So how do you tell IIS 7 to run in 32-bit mode? I found a terribly helpful post here that details of the situation (both a fix and the reasoning behind it). Basically, go into your IIS 7 manager console, find the application pool your app is running in, right-click on it, go to Advanced Settings, and change the Enable 32-bit Applications setting to true:

Editing the application pool properties in the IIS 7 Manager snap-in.

Now restart IIS (either via the snap-in or the command line w/net stop w3svc & net start w3svc) and you’re good to go. Easy enough, right? Pop open Task Manager again and you should see a lovely *32 next to the World Wide Web Worker Process (w3wp.exe), signifying that it’s basically running in 32-bit compatibility mode:

Task Manager showing IIS 7 running in 32-bit mode.

Hopefully your app should load fine now. Well, at least mine did.

13 Responses

  1. 魔方网 Says:

    Good article!
    Thank you!

  2. Kenny Says:

    Thanks for this tip! I was trying to do some .CSV importing and it was failing because of my 64-bit SQL installation. Saved me! Thanks again!

  3. Khyati Says:

    Thanks a bunch!! I was struggling to run my app on Server 2008, IIS7.5 box. Saved my day and leave too.

  4. samson Says:

    Thanks for the info…it helped us

  5. Geetha Rani Says:

    Thank you for putting this article. It was very useful for us.

  6. Ajay Singh Says:

    I was also facing the same problem and it got resolved by changing the “Enable 32-bit Applications” property at pool level. However it worked without restarting the IIS. I guess each pool based on the setting will have its own process which will get restarted when this property is changed.

  7. Randy Morris Says:

    This article is PRICELESS. I can not tell you how much time I spent digging endlessly through forums trying to fix a problem with iis7 not loading an older dundas upload control. I was really hoping to get the site up without recoding a buttload of pages while people are waiting for the site to be working. You are the man!

  8. Murtaza Dharwala Says:

    This post is very useful, I would like to evaluate what will be the difference of the performance when we run IIS in 32 bit mode from running in IIS in 64 bit mode.

  9. snevi Says:

    Thanks!! i surfed a lot of useless sites before getting here and they all were kind of tricky. This one is just simple and perfect 🙂

  10. Chris Says:

    This worked – yay!

    I have spent a day loading this -enabling that. This was the breakthrough.

    [What idiot company would make backward-compatibility a feature, rather than a default. Oh yea . .]

  11. Kishan Says:

    Thanks a lot yar… I was too worried. a simple setting could relieve me… Thank again.

  12. Run 32-bit IIS on 64-bit Server 2008 - Admins Goodies Says:

    […] the full rundown, see this article here, the important part […]

  13. Vanessa Says:

    Awesome article, helped me resolve my issue. Thanks a lot 🙂

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.