<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>OOP - There It Is - 64-bit</title>
    <link>http://www.vpsw.com/blogbaby/</link>
    <description>A Very Practical Blog</description>
    <language>en-us</language>
    <copyright>Dean Fiala</copyright>
    <lastBuildDate>Wed, 09 Jan 2008 05:05:38 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>dfiala@vpsw.com</managingEditor>
    <webMaster>dfiala@vpsw.com</webMaster>
    <item>
      <trackback:ping>http://www.vpsw.com/blogbaby/Trackback.aspx?guid=5d2f79e5-0c0b-4b18-8439-ea11f8b871dc</trackback:ping>
      <pingback:server>http://www.vpsw.com/blogbaby/pingback.aspx</pingback:server>
      <pingback:target>http://www.vpsw.com/blogbaby/PermaLink,guid,5d2f79e5-0c0b-4b18-8439-ea11f8b871dc.aspx</pingback:target>
      <dc:creator>Dean</dc:creator>
      <wfw:comment>http://www.vpsw.com/blogbaby/CommentView,guid,5d2f79e5-0c0b-4b18-8439-ea11f8b871dc.aspx</wfw:comment>
      <wfw:commentRss>http://www.vpsw.com/blogbaby/SyndicationService.asmx/GetEntryCommentsRss?guid=5d2f79e5-0c0b-4b18-8439-ea11f8b871dc</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Headaches.  Homicidal thoughts. 
Horrible alliterations.<br /><br />
All these things happened over the the last few days. 
<br /><br />
It all started when I needed to build 64-bit versions of a few .NET 2.0 apps (a wep
app, a windows service and a passel of supporting libraries).  This is actually
very simple to do. Visual Studio exposes a platform setting in the build configuration
for each project.  The default platform is anycpu.  Specifying x64 sets
the compiler option and instructs VS to build a 64-bit image (even on a 32-bit machine). 
Of course, doing this for a bunch of projects would be dull.  Fortunately, I
already have NANT scripts to build everything, so I added a platform parameter to
the compiler tasks and voila, a slew of 64-bit assemblies in 194 seconds. 
<br /><br />
Dropped the gooey mess on the 64-bit machine, and by gosh the web app worked and so
did the service.  Double checked that the 64-bit system was not running any 32-bit
assembly in <a href="http://support.microsoft.com/kb/896456">WOW</a> mode. Nope, all
64-bit baby!  Ran the applications through their paces, and they ran perfectly. 
.NET makes 64-bit apps happen with the flick of a (compiler) switch -- sweet!<br /><br />
Time to build the 64-bit installers for the web app and the service. Now, if 32-bit
deployment projects are the 3-eyed, 9-toed, humpbacked, perpetually sniffing step-chilldren
of .NET -- and they are -- 64-bit deployment projects make them look like the fairhaired,
first born heirs to the kingdom.  
<br /><br />
Just like any other app, deployment apps can be simply targeted to either platform. 
But finding the toggle is bit confusing.  It is not in the same place as "normal"
applications.  The platform can't be changed in the build configuration, you
must select the Installer in the Solution Explorer and click F4 to expose the properties. 
Selecting Properties... in the context menu for the installer does NOT expose the
same set of properties.  OK, a little swearing later, and the web app installer
is set to x64 bit and it builds the MSI. Woo hoo, looking good!<br /><br />
Time to test it on the x64 server.  An exception!  Ugghh.  BadFileImageFormat.  <a href="http://thedailywtf.com/">WTF</a>. 
Documentation time.  The error says I am trying to run a 64-bit image on a 32-bit
platform, but, but, but, I'm running a 64-bit image on 64-bit platform.  Some
googling, some double checking that a 32-bit assembly hadn't somehow screwed up the
MSI.  More swearing. Finally stumbled across this <a href="http://blogs.msdn.com/heaths/archive/2006/02/01/64-bit-managed-custom-actions-with-visual-studio.aspx">blog
post</a> which pointed me in the right direction. 
<br /><br />
The cause turned out to be a <a href="http://msdn2.microsoft.com/en-us/library/aa368066.aspx">Custom
Action</a> that updates the web.config file, sets some directory permissions and sets
up the application in IIS. The Custom Action is an installer class that is kicked
off by InstallUtil in the MSI.  Worked fine in 32-bit.  But, VS embeds the
32-bit version of InstallUtil in the MSI, even when a x64 platform has been targeted,
hence the BadFileImageFormat exception.  
<br /><br />
The workaround required downloading the Platform SDK and installing a tool named <a href="http://msdn2.microsoft.com/en-us/library/aa370557.aspx">Orca</a>. 
Orca lets you inspect/alter the MSI guts.  Pulled the 64-bit version of InstallUtil
from the x64 box and sucked it into the MSI using Orca. Saved the MSI and tried it
again. And behold it worked, Custom Action and all. Thank you <strike>Chuck Norris</strike> Heath
Stewart.<br /><br />
The service was bit trickier. I kept getting FileNotFound exceptions in the Windows
directory. But I wasn't trying to install anything in the Windows directory, which
was a bit perplexing.  The problem turned out to be the default directory for
installing the service had a space in it.  Yes, in 2008, this is still an issue.
Changed the default directory to something without spaces, and got around this error
only to run into the dreaded <b>InstallUtilLib.dll: Unknown Error., (NULL), (NULL),
(NULL)</b>.  More swearing.  Well, it turns out that InstallUtil doesn't
deal well with the way the installer package escapes path names when sending <a href="http://msdn2.microsoft.com/en-us/library/2w2fhwzz%28vs.71%29.aspx">data
to the Custom Action</a>.  So I just sent all the properties without the surrounding
quotes (since I was no longer allowing paths with spaces anyway) and the darn thing
finally worked.<br /><br />
There's got be a better way, the whole MSI process is so cobbled together, it is astounding
that anyone can create a usable installer without third party tools (and even they
seem hobbled by the Windows Installer determined quirkiness) or weeks of free time. 
<br /><br />
Now, all of this could have been avoided if I hadn't used Custom Actions.  But
there are no Standard Actions for:<br /><ul><li>
setting directory or file permissions</li><li>
setting up virtual directories in IIS<br /></li><li>
setting the ASP.NET version and application pool<br /></li><li>
updating configuration files</li></ul><br />
Also, the VS deployment project relies on a Custom Action to install the service,
instead of creating a service table in the MSI.  Not sure why this is, but tis
annoying to know it's there yet not exposed in the deployment project. If I had wanted
to dive into Orca, I could have used to it set up the table in the MSI, but my patience
had long since expired.<br /><br />
I'm not holding any hope that the situation will improve in the future.  As the
software world becomes ever more web-centered, there is even less call for building
installers.  With FTP and Xcopy it's easy enough to deploy web apps. Setting
up an app in IIS manually is trivial and .NET removes most of the need for dealing
with Registry foo. 
<br /><br />
If I have a client ask for install package again, I'm giving them a zip file and a
page of instructions.  Infinitely quicker than dealing with Misfit Solution Installers.<br /><p></p><img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=5d2f79e5-0c0b-4b18-8439-ea11f8b871dc" /></body>
      <title>You Go 64-bits And Whatya Get?</title>
      <guid isPermaLink="false">http://www.vpsw.com/blogbaby/PermaLink,guid,5d2f79e5-0c0b-4b18-8439-ea11f8b871dc.aspx</guid>
      <link>http://www.vpsw.com/blogbaby/PermaLink,guid,5d2f79e5-0c0b-4b18-8439-ea11f8b871dc.aspx</link>
      <pubDate>Wed, 09 Jan 2008 05:05:38 GMT</pubDate>
      <description>Headaches.&amp;nbsp; Homicidal thoughts.&amp;nbsp; Horrible alliterations.&lt;br&gt;
&lt;br&gt;
All these things happened over the the last few days. 
&lt;br&gt;
&lt;br&gt;
It all started when I needed to build 64-bit versions of a few .NET 2.0 apps (a wep
app, a windows service and a passel of supporting libraries).&amp;nbsp; This is actually
very simple to do. Visual Studio exposes a platform setting in the build configuration
for each project.&amp;nbsp; The default platform is anycpu.&amp;nbsp; Specifying x64 sets
the compiler option and instructs VS to build a 64-bit image (even on a 32-bit machine).&amp;nbsp;
Of course, doing this for a bunch of projects would be dull.&amp;nbsp; Fortunately, I
already have NANT scripts to build everything, so I added a platform parameter to
the compiler tasks and voila, a slew of 64-bit assemblies in 194 seconds. 
&lt;br&gt;
&lt;br&gt;
Dropped the gooey mess on the 64-bit machine, and by gosh the web app worked and so
did the service.&amp;nbsp; Double checked that the 64-bit system was not running any 32-bit
assembly in &lt;a href="http://support.microsoft.com/kb/896456"&gt;WOW&lt;/a&gt; mode. Nope, all
64-bit baby!&amp;nbsp; Ran the applications through their paces, and they ran perfectly.&amp;nbsp;
.NET makes 64-bit apps happen with the flick of a (compiler) switch -- sweet!&lt;br&gt;
&lt;br&gt;
Time to build the 64-bit installers for the web app and the service. Now, if 32-bit
deployment projects are the 3-eyed, 9-toed, humpbacked, perpetually sniffing step-chilldren
of .NET -- and they are -- 64-bit deployment projects make them look like the fairhaired,
first born heirs to the kingdom.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
Just like any other app, deployment apps can be simply targeted to either platform.&amp;nbsp;
But finding the toggle is bit confusing.&amp;nbsp; It is not in the same place as "normal"
applications.&amp;nbsp; The platform can't be changed in the build configuration, you
must select the Installer in the Solution Explorer and click F4 to expose the properties.&amp;nbsp;
Selecting Properties... in the context menu for the installer does NOT expose the
same set of properties.&amp;nbsp; OK, a little swearing later, and the web app installer
is set to x64 bit and it builds the MSI. Woo hoo, looking good!&lt;br&gt;
&lt;br&gt;
Time to test it on the x64 server.&amp;nbsp; An exception!&amp;nbsp; Ugghh.&amp;nbsp; BadFileImageFormat.&amp;nbsp; &lt;a href="http://thedailywtf.com/"&gt;WTF&lt;/a&gt;.&amp;nbsp;
Documentation time.&amp;nbsp; The error says I am trying to run a 64-bit image on a 32-bit
platform, but, but, but, I'm running a 64-bit image on 64-bit platform.&amp;nbsp; Some
googling, some double checking that a 32-bit assembly hadn't somehow screwed up the
MSI.&amp;nbsp; More swearing. Finally stumbled across this &lt;a href="http://blogs.msdn.com/heaths/archive/2006/02/01/64-bit-managed-custom-actions-with-visual-studio.aspx"&gt;blog
post&lt;/a&gt; which pointed me in the right direction. 
&lt;br&gt;
&lt;br&gt;
The cause turned out to be a &lt;a href="http://msdn2.microsoft.com/en-us/library/aa368066.aspx"&gt;Custom
Action&lt;/a&gt; that updates the web.config file, sets some directory permissions and sets
up the application in IIS. The Custom Action is an installer class that is kicked
off by InstallUtil in the MSI.&amp;nbsp; Worked fine in 32-bit.&amp;nbsp; But, VS embeds the
32-bit version of InstallUtil in the MSI, even when a x64 platform has been targeted,
hence the BadFileImageFormat exception.&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
The workaround required downloading the Platform SDK and installing a tool named &lt;a href="http://msdn2.microsoft.com/en-us/library/aa370557.aspx"&gt;Orca&lt;/a&gt;.&amp;nbsp;
Orca lets you inspect/alter the MSI guts.&amp;nbsp; Pulled the 64-bit version of InstallUtil
from the x64 box and sucked it into the MSI using Orca. Saved the MSI and tried it
again. And behold it worked, Custom Action and all. Thank you &lt;strike&gt;Chuck Norris&lt;/strike&gt; Heath
Stewart.&lt;br&gt;
&lt;br&gt;
The service was bit trickier. I kept getting FileNotFound exceptions in the Windows
directory. But I wasn't trying to install anything in the Windows directory, which
was a bit perplexing.&amp;nbsp; The problem turned out to be the default directory for
installing the service had a space in it.&amp;nbsp; Yes, in 2008, this is still an issue.
Changed the default directory to something without spaces, and got around this error
only to run into the dreaded &lt;b&gt;InstallUtilLib.dll: Unknown Error., (NULL), (NULL),
(NULL)&lt;/b&gt;.&amp;nbsp; More swearing.&amp;nbsp; Well, it turns out that InstallUtil doesn't
deal well with the way the installer package escapes path names when sending &lt;a href="http://msdn2.microsoft.com/en-us/library/2w2fhwzz%28vs.71%29.aspx"&gt;data
to the Custom Action&lt;/a&gt;.&amp;nbsp; So I just sent all the properties without the surrounding
quotes (since I was no longer allowing paths with spaces anyway) and the darn thing
finally worked.&lt;br&gt;
&lt;br&gt;
There's got be a better way, the whole MSI process is so cobbled together, it is astounding
that anyone can create a usable installer without third party tools (and even they
seem hobbled by the Windows Installer determined quirkiness) or weeks of free time. 
&lt;br&gt;
&lt;br&gt;
Now, all of this could have been avoided if I hadn't used Custom Actions.&amp;nbsp; But
there are no Standard Actions for:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
setting directory or file permissions&lt;/li&gt;
&lt;li&gt;
setting up virtual directories in IIS&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
setting the ASP.NET version and application pool&lt;br&gt;
&lt;/li&gt;
&lt;li&gt;
updating configuration files&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
Also, the VS deployment project relies on a Custom Action to install the service,
instead of creating a service table in the MSI.&amp;nbsp; Not sure why this is, but tis
annoying to know it's there yet not exposed in the deployment project. If I had wanted
to dive into Orca, I could have used to it set up the table in the MSI, but my patience
had long since expired.&lt;br&gt;
&lt;br&gt;
I'm not holding any hope that the situation will improve in the future.&amp;nbsp; As the
software world becomes ever more web-centered, there is even less call for building
installers.&amp;nbsp; With FTP and Xcopy it's easy enough to deploy web apps. Setting
up an app in IIS manually is trivial and .NET removes most of the need for dealing
with Registry foo. 
&lt;br&gt;
&lt;br&gt;
If I have a client ask for install package again, I'm giving them a zip file and a
page of instructions.&amp;nbsp; Infinitely quicker than dealing with Misfit Solution Installers.&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.vpsw.com/blogbaby/aggbug.ashx?id=5d2f79e5-0c0b-4b18-8439-ea11f8b871dc" /&gt;</description>
      <comments>http://www.vpsw.com/blogbaby/CommentView,guid,5d2f79e5-0c0b-4b18-8439-ea11f8b871dc.aspx</comments>
      <category>2.0</category>
      <category>64-bit</category>
    </item>
  </channel>
</rss>