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)
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:
- Open the resulting .msi in Orca from the Windows Installer SDK
- Select the Binary table
- Click the Tables menu and then Add Row
- Enter, for example, InstallUtil64 for the Name
- Select the Data row and click the Browse button
- Browse to %WINDIR%\Microsoft.NET\Framework64\v4.0.30319
- Select InstallUtilLib.dll
- Click the Open button
- Click the OK button
- Select the CustomAction table
- 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!