Register Shell Extension Context Menu (also on Windows x64). Part 2.

In first part I explained how we can easily create Shell Extension Context Menu with icon for Windows Explorer. Second step for adding this functionality to your application is a registration this dll as a COM component.

Of course you can do this by “Visual Studio x64 Win64 Command Prompt”, or “Visual Studio x64 Cross Tool Command Prompt” but usually you need to do it some setup package. It can be done in Installer class by following method:

private void registerDLL(string dllPath)




if (!File.Exists(dllPath))


Assembly asm = Assembly.LoadFile(dllPath);

var reg = new RegistrationServices();

if (reg.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase))



catch (Exception ex)





Everything will be OK, except x64 operation system J I wasted too much time on it and decided that solution must be solved in my blog too. There is reason in wrong InstallUtil.dll. Your setup package must have x64 version this assembly.

So…firstly we need to download Orca tool. It’s a database table editor for creating and editing Windows Installer packages and merge modules. The tool provides a graphical interface for validation, highlighting the particular entries where validation errors or warnings occur.

Then you need to build x32 installer and do following steps:

  1. Open the resulting .msi in Orca from the Windows Installer SDK
  2. Select the Binary table
  3. Click the Tables menu and then Add Row
  4. Enter, for example, InstallUtil64 for the Name
  5. Select the Data row and click the Browse button
  6. Browse to %WINDIR%\Microsoft.NET\Framework64\v4.0.30319
  7. Select InstallUtilLib.dll
  8. Click the Open button
  9. Click the OK button
  10. Select the CustomAction table
  11. For each custom action where the Source column is InstallUtil change the value to, for example, InstallUtil64.

Voila…we’ve got a new setup.msi file for x64 operation system which can register COM assembly.

Thanks and hope you won’t waste time as me!


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