November 2010 (1)
August 2010 (1)
July 2010 (1)
June 2010 (3)
July 2009 (3)
June 2009 (1)
May 2009 (1)
February 2009 (1)
January 2009 (1)
November 2008 (3)
October 2008 (4)
September 2008 (9)
August 2008 (6)
July 2008 (3)
June 2008 (3)
January 2008 (1)
November 2007 (2)
October 2007 (6)
September 2007 (5)
August 2007 (22)
July 2007 (6)
June 2007 (1)
May 2007 (3)
April 2007 (27)
March 2007 (8)
February 2007 (6)
September 2006 (2)
August 2006 (4)
July 2006 (9)
June 2006 (17)
May 2006 (20)
April 2006 (12)
March 2006 (9)
February 2006 (4)
January 2006 (3)
December 2005 (2)
November 2005 (4)
October 2005 (5)
September 2005 (37)
August 2005 (83)
July 2005 (6)

Active Directory / LDAP (0)
ASP.Net (19)
Blackberry Development (4)
c# (34)
c++ (3)
Code Camp (1)
Excel (1)
Exchange (3)
Front Page 2003 (6)
FTP User Editor (4)
HTML / CSS / DHTML (8)
IIS (146)
IIS - Log Parser (7)
IIS / FTP (12)
IIS / Tools / Administration (42)
IIS / Tools / Authentication (6)
IIS / Tools / Compression (8)
IIS / Tools / Crash & Hang (12)
IIS / Tools / ISAPI Filters (17)
IIS / Tools / Log Files (17)
IIS / Tools / Scripts (28)
IIS / Tools / Security (9)
IIS / Tools / SSL (6)
IIS 7 (3)
Internet Information Server (1)
Me (Chris Crowe) (6)
MIME Types (1)
Misc (72)
Oulook Express (2)
Silverlight (1)
SQL Server (27)
SQL Server CTE (1)
Vista (15)
Vista Gadgets (8)
Visual Studio (11)
Voice over BroadBand (1)
Windows (33)
Windows Powershell (3)
Windows Sharepoint Services (0)
Windows Sharepoint Services (15)
Windows Vista (14)
Wine Cellar (1)
WMI (8)

Archive

November 2008 (3)

64-bit Managed Custom DLL Actions with Visual Studio do not work properly

I have recently been creating a new UI Module for IIS 7 and as part of this I wanted to install my module automatically using a MSI file. With the help of CarlosAg from the IIS product team I have made my UI module work really well and also managed to create a setup for it.

The setup installs the files into the GAC, and does the registration and de-registration in the IIS administration.config file during install/uninstall.

For details on how to do this please go to http://blogs.msdn.com/carlosag/archive/2008/11/10/CreatingSetupProjectForIISusingVisualStudio2008.aspx

 

So it was all working fine but when I deployed it to a 64Bit machine I got the following error during the install.

64BitIIS7InstallError

Now I was lost but Carlos did some digging and found an article that explained what happened which you can read by clicking the link below.

http://blogs.msdn.com/heaths/archive/2006/02/01/64-bit-managed-custom-actions-with-visual-studio.aspx

Basically the problem is (quoted from heath's blog)

When you build the Windows Installer project in Visual Studio it embeds the 32-bit version of InstallUtilLib.dll into the Binary table as InstallUtil. When Windows Installer executes your managed custom action it actually is calling the ManagedInstall entry point function from InstallUtilLib.dll as a type 1 deferred custom action (1025) which creates an instance of the CCW System.Configuration.Install.IManagedInstaller interface and runs your Installer classes. Since the native InstallUtilLib.dll is 32-bit it loads the 32-bit Framework which will throw the BadImageFormatException since your managed class library is 64-bit.

So his blog goes on with a method you can use to update the DLLs binary data in the MSI file using a tool called ORCA which can be downloaded from http://www.technipages.com/download-orca-msi-editor.html

I wanted a more automated solution so I wrote the following code which uses the Windows Installer COM Object to open the database and replace the binary file.

 

My App.Config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
      <add key="InstallUtil64BitFileSpec" value="\\ccrowe-test\c$\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtilLib.dll"/>
      <add key="MSIFileSpec" value="C:\dev\Projects\IIS7\Extensibility\FTPADUserEditor\SetupFTPADUserEditor\Debug\SetupFTPADUserEditor.msi"/>
  </appSettings>
</configuration>

 

My C# Source

using System;
using System.Configuration;

// You must add a reference to the COM Object "Microsoft Windows Installer Object Library 1.0" 
// which is located in c:\windows\system32\msi.dll

// You must also add a reference to System.Configuration

// For more details of why this code was written see the following site
// http://blogs.msdn.com/heaths/archive/2006/02/01/64-bit-managed-custom-actions-with-visual-studio.aspx
namespace Fix64BitMSIFile
{
    class Program
    {
        static void Main(string[] args)
        {
            bool ChangesMade = false;

            Console.WriteLine("Update an MSI File with a 64bit version of InstallUtilLib");
            Console.WriteLine();

            string InstallUtil64BitFileSpec = ConfigurationManager.AppSettings["InstallUtil64BitFileSpec"];
            string MSIFileSpec = ConfigurationManager.AppSettings["MSIFileSpec"];

            if (System.IO.File.Exists(InstallUtil64BitFileSpec) == false)
            {
                Console.WriteLine("File Not Found : " + InstallUtil64BitFileSpec);
                return;
            }
            if (System.IO.File.Exists(MSIFileSpec) == false)
            {
                Console.WriteLine("File Not Found : " + MSIFileSpec);
                return;
            }

            Console.WriteLine("MSIFile:" + Environment.NewLine + MSIFileSpec);
            Console.WriteLine();
            Console.WriteLine("InstallUtil: " + Environment.NewLine + InstallUtil64BitFileSpec);
            Console.WriteLine();
            Console.WriteLine("Opening the MSI File");
            WindowsInstaller.Installer i = (WindowsInstaller.Installer)new Fix64BitMSIFile.Installer();
            WindowsInstaller.Database db = i.OpenDatabase(MSIFileSpec, WindowsInstaller.MsiOpenDatabaseMode.msiOpenDatabaseModeTransact);
            Console.WriteLine("Running SQL Query for InstallUtil in the Binary MSI table");

            // NOTE: The ` is correct in the SQL statement below - it is not " or ' 

            WindowsInstaller.View v = db.OpenView("SELECT `Name`,`Data` FROM `Binary` where `Binary`.`Name` = 'InstallUtil'");
            v.Execute(null);
            WindowsInstaller.Record Record = v.Fetch();
            if (Record != null)
            {
                Console.WriteLine("Updating the Binary Data for InstallUtil");
                Record.SetStream(2, InstallUtil64BitFileSpec);
                v.Modify(WindowsInstaller.MsiViewModify.msiViewModifyUpdate, Record);
                ChangesMade = true;
            }
            else
            {
                Console.WriteLine("Error : InstallUtil not found in the Binary MSI Table");
            }
            v.Close();
            if (ChangesMade)
            {
                Console.WriteLine("Commiting the changes to the database");
                db.Commit();
            }

            Console.WriteLine();
            Console.WriteLine("Completed.....");
        }
    }
}

 

Hopefully this may help someone else in the future.

In the mean time it is back to the development of my IIS 7 Module....


URL Rewrite Module for IIS 7.0 Release To Web (RTW)

The IIS team has made the URL Rewrite Module for IIS 7.0 Release To Web (RTW) available for download. This is a final, production-ready release that is officially supported by Microsoft.

Basically I have just copied and pasted the details below because there is not a lot else to say - everything you want should be covered below.

Install the URL Rewrite Module for IIS 7.0 RTW today!

The installer for URL Rewrite module includes an update for ASP.NET runtime. The update has fixes for bugs specific to URL rewriting. The update is applied only if the machine where URL Rewrite module is being installed has .NET Framework version 3.5 SP1 or higher. If required version of .NET Framework is installed after URL Rewrite module has been installed, then the ASP.NET update can be applied by re-running URL Rewrite module installer in repair mode.

Features:

Here is the complete list of features supported by URL Rewrite module:

  • Rules-based URL rewriting engine. Rewrite rules are used to express the logic of what to compare/match the request URL with and what to do if comparison was successful. Web server and site administrators can use rewrite rule sets to define URL rewriting logic.

  • Regular expression pattern matching. Rewrite rules can use ECMA-262 compatible regular expression syntax for pattern matching.

  • Wildcard pattern matching. Rewrite rules can use Wildcard syntax for pattern matching

  • Global and distributed rewrite rules. Global rules are used to define server-wide URL rewriting logic. These rules are defined within applicationHost.config file and they cannot be overridden or disabled on any lower configuration levels. Distributed rules are used to define URL rewriting logic specific to a particular configuration scope. This type of rules can be defined on any configuration level by using web.config files.

  • Access to server variables and http headers. Server variables and HTTP headers provide additional information about current HTTP request. This information can be used to make rewriting decisions or to compose the output URL.

  • Various rule actions. Instead of rewriting a URL, a rule may perform other actions, such as issue an HTTP redirect, abort the request, or send a custom status code to HTTP client.

  • Support for IIS kernel mode and user mode output caching. IIS 7.0 output caching provides significant performance improvements for web applications. URL rewrite module is fully compatible with both types of output caching. This means that it is possible to safely cache responses for rewritten URL’s and thus boost the performance of web applications that rely on URL rewriting.

  • Rewrite maps. Rewrite map is an arbitrary collection of name-value pairs that can be used within rewrite rules to generate the substitution URL during rewriting. Rewrite maps are particularly useful when you have a large set of rewrite rules, all of which use static strings (i.e. there is no pattern matching used). In those cases, instead of defining a large set of simple rewrite rules, you can put all the mappings between input URL and substitution URL as keys and values into the rewrite map, and then have one rewrite rule which references this rewrite map to look up substitution URL based on the input URL.
  • Failed Request Tracing support. IIS7.0 Failed Request Tracing can be used to troubleshoot errors related to URL rewriting.

  • Extensible Rule templates. Rule template is an extension for URL rewrite module user interface, that simplifies creation of rewrite rules for a particular task.  The GoLive release of the module includes 3 built-in rule templates, plus it allows plugging in any number of custom templates.

  • UI for testing of regular expression and wildcard patterns. A GUI tool for testing rule patterns is included into the module’s user interface. The tool can be used to quickly check how the regular expression or wildcard pattern works. Also, it can be used for troubleshooting and debugging of problems related to pattern matching.

  • UI for managing rewrite rules and rewrite maps. Rewrite rules and rewrite maps can be added, removed and edited by using “URL Rewrite Module” feature in IIS Manager.

  • GUI tool for importing of mod_rewrite rules. URL rewrite module includes a GUI tool for converting rewrite rules from mod_rewrite format into an IIS format.
  • String manipulation functions. Built-in string manipulation functions can be used to convert URLs to lowercase and to perform URL encoding and decoding.

Walk-through's:

References and guidance:


Microsoft Management Console has stopped working - Windows Server 2008 MMC Crashes when adding any snapin

using Server Manager and any other 'pre-defined' MMC consoles open up and function just fine, but if I launch a separate mmc console and attempt to add a snapin, MMC crashes with "Microsoft Management Console has stopped working" and the following is found in the Windows Application Event Log

 

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="Application Error" /> 
  <EventID Qualifiers="0">1000</EventID> 
  <Level>2</Level> 
  <Task>100</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2008-11-05T22:33:57.000Z" /> 
  <EventRecordID>117443</EventRecordID> 
  <Channel>Application</Channel> 
  <Computer>SERVER</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>mmc.exe</Data> 
  <Data>6.0.6001.18000</Data> 
  <Data>47919524</Data> 
  <Data>ntdll.dll</Data> 
  <Data>6.0.6001.18000</Data> 
  <Data>4791adec</Data> 
  <Data>c0000374</Data> 
  <Data>00000000000a6e97</Data> 
  <Data>1c2c</Data> 
  <Data>01c93f969190348b</Data> 
  </EventData>
  </Event>

image

Looking in "Problem reports and Solutions"  (just click on the Start Menu and type in Problem and hit enter when it finds the tool) I find this data

image

There is no solution to this problem from Microsoft at the time of this post.

I have found a work-around to actually alllow you to work in most cases.  Quite often the MMC Snapin you want to add may be available on another computer such as a VISTA machine. If so you can add your snapin on the Windows Vista machine and then save the MMC Console and then copy the console.msc file to the Windows Server 2008 machine and the just execute it from there.

 

Interestingly you do not have to actually add a snapin to cause the problem. Following the steps below cause the issue as well.

  • load MMC
  • Select File - Add/Remove Snapin
  • Click Cancel

I also found this post so at least one other has the same issue as me : http://www.mombu.com/microsoft/mmc/t-win-2008-mmc-crashing-whenever-i-add-a-snapin-1738935.html