How Hard Can it Be?

Posted: October 19, 2010 in Software Development

Recently a friend of mine asked me for help in one of his projects. He is managing a site developed using ASP, he did not start it, he just kind of inherited it. Not ASP.Net though, classical ASP.

So, imagine this, you are a more or less experienced developer, but you have never developed in ASP. Someone asks you to lend a hand in an ASP project. You think, I feel pretty confident about doing web development, how hard can it be? Well, knowing this now, I can say this: harder than it should.

If you had to enumerate what you had to do before you starting something like this, it would probably look a bit like this:

  1. Install a web server that can serve ASP pages. Internet Information Server (IIS) is really the only choice here.
  2. Install ASP in IIS. IIS does not support ASP out of the box, you have to install it
  3. Get a copy of the source code and put it running on your local machine
  4. Start developing

Sounds pretty easy huh? Well it should, however for me it was not (it never is, disagree? read this).

Let us start by (1). Installing IIS. The preferred way to get IIS running in your machine nowadays is to use Microsoft Web Platform Installer (WPI). If you do not know what I am talking about, check it out, it is really nice (if it is works in your machine).

By the way, I am using a Windows 7 Professional 64Bit.

Here is what happened, I would start WPI and choose Web Platform and Web Server. Actually I chose the customize option and realized I could install ASP from WPI, so I would get 1 & 2 at the same time. At that time I thought, man this WPI is really nice.

Installing a Web Server

However… as soon I clicked the Install button… tragedy happened…

It would not install a thing, everything would throw an error. I do not actually recall the exact error, or what was in the log (update: I had this in my browser search history: web platform installer Unattended setup returned ‘-2147467259’; and this one: web platform installer download manager error), I do know that I eventually found out why it was throwing all those errors, my TrustedInstaller.exe was missing. The process of finding out this was happening because TrustedInstaller was missing was not obvious at all. Making a long story short, I discovered it was missing when I tried to do run SFC (System file checker) and got another error (sorry this one I did not really wrote down, but it is easy to provoke if you really want to, just delete TrustedInstaller and then try to run SFC :P)

Oh, and just another symptom that a missing TrustedInstaller will cause: if you go to Control Panel->Programs->Turn Windows features On Off you’ll get an empty list.

By the way, you should have your TrustedInstaller.exe file in C:\Windows\servicing.

I still do not know for sure how it got deleted, but it turns out that Avast antivirus might sometimes delete it. I do use Avast so, that might have been it…

So now what? You have a pretty important system file missing, what do you do? Some people would just go about formatting their pc and reinstalling everything they need. Some are a bit more organized and they keep a clean image file of their system that they have created after a fresh installation.

I am neither of these people. I do not keep an image of a fresh install nor am I willing to format my PC every time something like this happens.

I do not know if you know this but you can access individual files from your Windows installation disk. Here’s how you do it: download 7-Zip file manager, then insert your Windows DVD and browse to sources/install.wim. Use 7-Zip to open it.

Inside install.wim you will find a bunch of folders and a file named 1.xml. I’d advise you to open it in Internet Explorer if you do not have any program that can automatically indent it for you (it has no line breaks). Look for the <Image Index=”x”> tag that contains a child element named ‘NAME’ that corresponds to your version of Windows. In my case it was <NAME>Windows 7 PROFESSIONAL</NAME> inside <IMAGE INDEX=”3“> meaning that the files for my installation are under the folder named 3.

Now you just have to browse through your corresponding folder and extract the file you need. In this case TrustedInstaller.exe under Windows\servicing.

If you have never done something like this before, you will be surprised if you try to copy that file to your installation of Windows. You will be presented with a “Permission denied” error message. You have to take ownership of that folder (using takeown) and give permissions to it before you can copy the file there.

Ok! After all this I was able to install IIS 7.5 and ASP using the WPI! What should have happened here after the install had finished, is me creating a simple ASP file, putting it under C:\inetput\wwwroot\ and then opening http://localhost/helloworld.asp and seeing magic happen. This did not work…

Although I had used the customize option in WPI and chosen to install IIS and ASP apparently, regarding ASP, nothing happened. I do not actually know for sure if ASP was installed by WPI or not, but I know that it was not ready to be used in IIS. To make it work you have to go to Control Panel->Programs->Turn Windows Features On Off and choose: Internet Information Services->World Wide Web Services->Application Development Features->ASP.

Now helloworld.asp works!

For making the real project work copy it to C:\Inetput\wwwroot\YourProject. Now, I am not entirely sure, but I think it did not work at that time, you have to open a console as an administrator and takeown of C:\Inetput\wwwroot\YourProject like this: takeown /f C:\Inetput\wwwroot\YourProject -r. And then edit the permissions using Explorer by right-clicking in C:\Inetput\wwwroot\YourProject, and then give permissions to your user and IIS_USRS.

The project my friend sent me had some errors, but I could not see much when I tried to run it. What I got from the browser was a “friendly” error message that hid the error details from me. Actually IIS does not provide that information at all. To get ASP errors to be displayed in Internet Explorer you have to configure IIS to display them: Open IIS manager, go to ASP->Compilations->Debugging Properties and enable Scrip Error Message.

Then disable Friendly Error Messages in IE by going to Tools->Internet Options->Browsing and then disable Show Friendly HTTP Error Messages.

But the story does not end here… The site was really old and was accessing a Microsoft Access Database. When I tried to run it I got this message:

Microsoft OLE DB Provider for ODBC Drivers error ‘80004005’

[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

Making a long story short (again!), there aren’t any 64-Bit drivers for Access. You can try to install this, but beware, I installed the 32 bit version by mistake and then I could not install the 64 bit version. I tried uninstalling the 32 bit installation and then installing the 64 bit one, just to get a message from the 64 bit version prompting me to uninstall the 32 bit version that I had already uninstalled!

But really, the easiest way is not that one (you probably have to have Access installed for this to work. I did, so I cannot really tell if this would work otherwise). Change IIS’s Application Pool to run in 32 Bit mode. To do this open IIS manager, then go to Application Pools; to your relevant application pool, select it and in the right pane select Advanced Settings… and in (General) set Enable 32-Bit Applications to True. And now you are done! At least I was.

So… how hard can it be? Harder than I had imagined, but then again nothing that should strike you as being out of the ordinary if you have done this kind of thing a couple of times. The truth is, it really rarely works at the first try.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s