Scott Hanselman

32bitness and 64bitness and migrating DasBlog on IIS7 and ASP.NET under Vista64

August 7, '07 Comments [4] Posted in ASP.NET | DasBlog | Musings
Sponsored By

After building the QuadPowerPC and getting it setup with Vista 64, the next step was to get DasBlog building so I could continue development. I installed Orcas Visual Studio 2008 first. Then I realized that I hadn't installed IIS on Vista yet. Doh!

Getting an existing Web App to Compile on Vista64

  • Install IIS: Go into Programs and Features and click "Turn Windows Features on or off." Only certain Vista SKUs have Full IIS - I believe Business, Enterprise and Ultimate. The Home SKUs have a limited version that will serve 3 requests. Enough to develop on, but that's about it.
    Windows Features
    The easiest thing for a developer machine is to turn all the checkboxes on from IIS on down.
    Note: This is a wacky dialog and unless the box is actually CHECKED ("filled" with color doesn't count) then it won't install everything. Open up the tree and make sure.
  • Pick an IIS Pipeline Mode: There are two modes for ASP.NET apps under II7. There's the integrated pipeline, and the classic pipeline.
    If you just create an application and run your existing app with the defaults, like I did, you'll likely see something like this (Note the incredibly detailed error message that I can ACTUALLY do something with...That's hot.):
    IIS 7.0 Detailed Error - 500.0 - Internal Server Error - Windows Internet Explorer (2) 
    At this point I have two choices, I can migrate my httpModules section using this command line expression:
    %systemroot%\system32\inetsrv\APPCMD.EXE migrate config "Default Web Site/DasBlog2"
    Or I can make an AppPool that is configured to use the "classic" pipeline - meaning, it'll use HttpModules just as before with this command line:
    %systemroot%\system32\inetsrv\APPCMD.EXE set app "Default Web Site/DasBlog2" /applicationPool:"Classic .NET AppPool"
    Either expression needs to be run from an administrator command line.
    Internet Information Services (IIS) Manager
    If you change your mind, you can always move your app between AppPools, or make as many as you like. Notice the IIS7-style admin tool shows you what Pipeline type you've chosen.
    If just use the First Option and just stick with classic mode, things will work fine and I don't have to change anything in my web.config. Let's see what happens if I choose The Second Option...
    %systemroot%\system32\inetsrv\APPCMD.EXE migrate config "Default Web Site/DasBlog2"
    Successfully migrated section "system.web/httpModules".
    Successfully migrated section "system.web/httpHandlers".
    At this point the newly written web.config has a new section at the bottom.

    NOTE: There appears to be an obscure bug with this tool when migrating web.configs with the old-style ASP.NET 1.1 browserCaps section. More on that here. Backup your web.config before running this, or any other tool!

    Notice that the modules and handlers have moved to a new system.webServer section, the modules have been marked as managedHandler and the handlers have a preCondition that they are run in integratedModule under the 2.0 runtime. It's worth noting, however, that the original httpHandlers section under system.web remains. This means you can run under both modes with this migrated web.config file, but if you're switching around, you'll need to keep those sections in sync - or, just pick a mode and stick with it.
    <system.webServer>
        <modules>
            <add name="UrlMapperModule" type="newtelligence.DasBlog.Web.Core.UrlMapperModule, newtelligence.DasBlog.Web.Core" preCondition="managedHandler" />
    ...
        </modules>
        <handlers>
           <add name="*.blogtemplate_*" path="*.blogtemplate" verb="*" type="System.Web.HttpForbiddenHandler" preCondition="integratedMode,runtimeVersionv2.0" />
    ...
        </handlers>
      <validation validateIntegratedModeConfiguration="false" />
    </system.webServer>
  • Convert and Compile: After doing this migration I opened the main solution in Visual Studio 2008 and it converted and compiled, no problem. Most 2.0 projects will convert just fine.
  • Check Your Bitness: After migrating the web.config and building in Visual Studio 2008 I ran the application, I got the Yellow Screen of Death telling me: "System.BadImageFormatException: Could not load file or assembly 'BasicFrame.WebControls.BasicDatePicker' or one of its dependencies."
    YellowScreenofDeath
    This error is slightly more obscure, but still fairly easily dealt with. Remember that I'm on Vista64. Open up the Advanced Settings of the AppPool you're running in and notice the option "Enable 32-Bit Applications." At this point, I have another choice.
    Advanced Settings
    I could switch this AppPool to a 32-bit Worker Process. I could tell because itwould say "w3wp.exe *32" in TaskManager. Or, I could find out why this is not working and get DasBlog running on 64-bit.
    I'll choose the latter.
    Open up a Visual Studio Command Prompt and run corflags.exe on the offending assembly.
    Administrator Visual Studio 2008 Beta2 x64 Win64 Command Prompt
    Mine says:
    D:\dev\DasBlog\lib>corflags BasicFrame.WebControls.BasicDatePicker.dll
    Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  3.5.20706.1
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Version   : v2.0.50727
    CLR Header: 2.5
    PE        : PE32
    CorFlags  : 11
    ILONLY    : 1
    32BIT     : 1
    Signed    : 1


    Notice the 32bit: 1 value. Looks like because the company that sells this assembly used Xenocode's Postbuild Obfucastor and it requires a CPU decision. Consequently I pay the price. Kind of lame.
    However, easily solved because Basic Date Picker has a 64-bit version available for download. I swap it out and check it with corflags...

    D:\dev\DasBlog\lib>corflags BasicFrame.WebControls.BasicDatePicker.dll
    Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  3.5.20706.1
    Copyright (c) Microsoft Corporation.  All rights reserved.

    Version   : v2.0.50727
    CLR Header: 2.5
    PE        : PE32
    CorFlags  : 9
    ILONLY    : 1
    32BIT     : 0
    Signed    : 1

    Still with me? Here's the funny part. It's not the 32BIT Flag that actually indicates if the assembly is 32bit or 64bit. It a property that tries to "insist" that the assembly run in a 32-bit process. You can, sometimes force it back and forth with corflags:

    D:\dev\DasBlog\lib>corflags.exe /32bit+ BasicFrame.WebControls.BasicDatePicker.dll
    Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  3.5.20706.1
    Copyright (c) Microsoft Corporation.  All rights reserved.
    corflags : error CF012 : The specified file is strong name signed.  Use /Force to force the update.
    D:\dev\DasBlog\lib>corflags.exe /32bit+ BasicFrame.WebControls.BasicDatePicker.dll /force
    Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  3.5.20706.1
    Copyright (c) Microsoft Corporation.  All rights reserved.
    corflags : warning CF011 : The specified file is strong name signed.  Using /Force will invalidate the signature of this image and will require the assembly to
    be resigned.
    But I can't because it's strong named and I don't have the key to sign it with, and I'm getting a little far down a silly road. Why would you want to compile a .NET assembly specific to 32-bit or X64, or IA? Usually because you're P/Invok'ing into a x64 specific native dll.
    The interesting things that corflags tell us are these:
    • CLR Header: The compiler version...2.0 is .NET 1.1, 2.5 is .NET 2.0 and 3.0 is .NET 3.5. Don't ask. ;)
    • PE (Portable Executable): PE32 is 32bit and PE32+ is 64-bit.
    • 32BIT: Are we asking to force 32-bit execution or not?

Anyway, I recompiled with the 64-bit version and all is well. I'm now running DasBlog compiled under Visual Studio 2008 on Vista 64 running under IIS7. All very smooth. Here's the "It's Not That Scary™ Summary":

It's Not That Scary™ Summary

  • Install IIS
    • Pick a Pipeline Mode and Migrate if needed
  • Compile
    • Confirm Bitness if Error.

So, really, just two steps if I'd been on Vista32 and already had IIS7 installed. Thanks to Richard Lander for all his tips and pointers! If there's mistakes in this post, they are mine, and he'll surely show up and correct them in the comments. :)

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Wednesday, August 08, 2007 4:59:21 AM UTC
Thanks! Just yesterday I got to the date picker issue, downloaded the 64-bit version, and ran out of time. Keep on doing the dirty work - just make sure you let me know about it when you're done.
Wednesday, August 08, 2007 12:58:49 PM UTC
Its not that scary - I ran into a few puzzling issues with one site, regarding wildcard mapping and url rewriting - see my blog post about it - but nothing crazy yet ;)
Wednesday, August 08, 2007 9:57:11 PM UTC
Good info, Scott.

Now the real question is -- have you finished polluting your new x64 machine with all these programs and add-ons? Since you had to enable IIS, you appeared to have installed Visual Studio 2008 Beta 2... I assume you plan on upgrading this to RTM come next February.

I guess you didn't use a virtual machine for this "development" PC huh?

I bet next year this time you're going to be telling us how you need to re-install your PC because its dorked up and things aren't running as well as they did your first week.


Mike Vann
Wednesday, August 08, 2007 10:30:59 PM UTC
Mike - So negative! ;) I installed Visual Studio 2008 but that's about it. I have it on good assurances that VS2008 uninstalls cleanly. So far I've only installed like a dozen apps, and most were 64-bit and none were drivers.

I've started using this whole "VM as everyday machine" thing and I'm loving it. My XP VMs run faster than my last computer! Now on THAT VM I've made a complete mess. I just drag over anything that I get the urge to install and drop it on that VM. It works great.
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.