Simon Harriyott

FileNotFoundException with CustomActions in Windows Installer

I'm building an installer with .NET 2.0 at the moment. I've been adding CustomActionData to the CustomAction dll, which includes a path. After adding a couple of new parameters, I started getting this message:
Exception occurred while initializing the installation:
System.IO.FileNotFoundException: Could not load file or assembly
'file:///C:\Windows\system32\Files\Company\Product\CustomActions.dll' or one of its dependencies. The system cannot find the file specified..

Now, I'm not actually trying to put the custom action in system32, it should be going under Program Files. The problem turned out to be a CustomActionData parameter. Here are the two values I tried - the first works and the second fails:

/installpath="[ProgramFilesFolder][Manufacturer]\[ProductName]"
/installpath="[ProgramFilesFolder][Manufacturer]\[ProductName]\"

What seems to be happening is that the \" is escaping the quote. The installer must be putting extra parameters after the supplied string, which are used to locate the CustomActions dll. Because the last quote is escaped, the value of the hidden parameters is appended to my installpath parameter, and the installer "loses" the CustomActions dll. I think that this probably counts as a bug in the installer.

This one has been bugging me all afternoon, and I didn't have much luck with Google. I've laden this post with keywords, so hopefully someone else will benefit from my hideous afternoon. [n.b. we have no internal mechanism for recording findings like this, so I use this blog as a personal store for non-IPR work stuff].

Update: I needed too use [SourceDir] to, but this didn't work, unless there trailing slash was present!. This is the opposite of the previous behaviour, so the second one of these works and the first one fails. Weird.

/installedfrom="[SourceDir]"
/installedfrom="[SourceDir]\"
21 November 2006