Aug 29, 2012

IIS - running 32 bit dlls on a 64 bit machine.

In a recent project I was faced with this situation.
The dataAccess project (xxx.dataaccess.dll) needed to access the oracle DB for some save operations.
We were using the default .Net Framework dll for Oracle data access (system.Data.OracleClient.dll) and not the ODP.Net one (Oracle.DataAccess.dll).
We found that in a 64 bit machine there was no way  to connect to the 64 bit version of the dll and the calls would fail with a [BadImageFormatException.]

To avoid this we had to compile the dataaccess project in 32 bit mode (PlatForm:Active(x86) and Configuration: Active(Release)). This would force the app to connect to the 32 bit version of the dll always.

When the bits were dropped to the web server, following a daily build,  we found that during the first access the site was throwing up an error: Unable to find the file or assembly xxx.dataaccess... BadImageFormatException... blah blah...

After much toil I found that in a 64 bit machine, IIS will always run in 64 bit unless specifically instructed to.

The process for enabling it is as follows.

Open IIS Manager>Open Application Pool> Select the app pool used for the site>right click>select "Advanced settings" > Navigate to the field "Enable 32 bit Applications" and select True from the dropdown.

Recycle the app pool or restart the IIS.

The site will be running fine after this..

:)

Aug 16, 2012

Asp.Net Mvc App showing Directory Listing after deployment..

Task: To set up a fresh web environment.
Specs for the web site: Asp.net MVC 3 + EF 4.1 + MS Sync framework 2.1
Specs for the site: Windows 2008 R2 + IIS 7.5
Steps:
1. Installed the Prerequisites (IIS + ASP.Net MVC 3 + EF + MS Sync Framework + Sql Server express etc..)
2. Copied the bits from a working server and dropped to the appropriate folder.
3. Created a Virtual Directory, inside the IIS, targeting the folder.
4. Set up the app pool.
5. Launched the site..

After initial hiccups like setting up the DB account for the app pool.. and some other smaler ones regarding the web.config, I was stuck at the following...
The website was continuously displaying the directory listing for the site and not the site itself..

Cause:
IIS is not using the ASP.Net Mvc dlls to render the site and instead is looking for a default webpage.

Solution:
  1. Open Command prompt
  2. Go to C:\Windows\Microsoft.NET\Framework\ folder.
  3. Run aspnet_regiis -ir