sharpshell
sharpshell copied to clipboard
Incorrect registration when using Wix Installer with File Associations
SharpShell v2.7.2 IconHandler Extension
I think I've encountered a bug when attempting to use ServerRegistrationManager from a Wix custom action. If I use the ServerRegistrationManager from the command line, I don't have any issues.
My Wix installer sets up a file association for the file extension '.uaproj'. It also sets a default action to open my application with that file as file argument.
<ProgId Id="uaprojFile" Description="UA Project File" Icon="uaProjIcon">
<Extension Id="uaproj" ContentType="application/uaproj ">
<Verb Id="open" TargetFile="Toolbox.exe" Argument=""%1"" />
</Extension>
</ProgId>
I call the server registration manager as follows from Wix:
<!-- Define custom actions to register and unregister the shell extensions -->
<SetProperty Id="InstallShell" Value=""[#ServerRegistrationManager.exe]" install "[#IconShellExtension.dll]" -os64 -codebase" Sequence="execute" Before="InstallShell"/>
<CustomAction Id="InstallShell" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="no" />
<SetProperty Id="UninstallShell" Value=""[#ServerRegistrationManager.exe]" uninstall "[#IconShellExtension.dll]" -os64 -codebase" Sequence="execute" Before="UninstallShell"/>
<CustomAction Id="UninstallShell" BinaryKey="WixCA" DllEntry="WixQuietExec" Execute="deferred" Return="check" Impersonate="no" />
I believe what is happening is that when registering the Icon Handler extension, its finding a key already exists, and creates a new registry key 'uaproj.1'. instead of using uaprojFile.
I sometimes get an error in the Wix log, but I believe this is due to the cleanup not working correctly when performing an uninstall:
WixQuietExec: ========================================
WixQuietExec: SharpShell - Server Registration Manager
WixQuietExec: ========================================
WixQuietExec:
WixQuietExec: Tools.IconShellExtension.dll failed to register.
WixQuietExec: RegAsm : error RA0000 : An error occurred inside the user defined Register/Unregister functions: System.InvalidOperationException: Unable to create a new class 'uaproj.1' for extension '.uaproj'. That class is already in use by application 'uaproj Application'.
WixQuietExec: at SharpShell.ServerRegistration.FileExtensionClass.Get(IRegistryKey classesKey, String fileExtension, Boolean createIfMissing)
WixQuietExec: at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
WixQuietExec: at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
WixQuietExec: at System.Linq.Enumerable.ToArray(IEnumerable`1 source)
WixQuietExec: at SharpShell.ServerRegistration.ServerRegistrationManager.CreateClassNamesForAssociations(AssociationType associationType, IEnumerable`1 associations, RegistrationType registrationType)
WixQuietExec: at SharpShell.ServerRegistration.ServerRegistrationManager.RegisterServerAssociations(Guid serverClsid, ServerType serverType, String serverName, IEnumerable`1 associationAttributes, RegistrationType registrationType)
WixQuietExec: at SharpShell.SharpShellServer.DoRegister(Type type, RegistrationType registrationType)
I can fix the registration manually if I copy the value contained in HKCR\uaproj.1\ShellEx\IconHandler
into HKCR\uaprojFile\ShellEx\IconHandler
.
Oddly, it works fine if I run the server registration manager from a command line outside of the Wix install process, it correctly sets up a registry key under HKCR\uaprojFile\ShellEx\IconHandler
and does not create one under HKCR\uaproj.1\ShellEx\IconHandler
.