• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3417
  • Last Modified:

net Setup Project >> Custom Actions >> [TARGETDIR], error when user inputs path with spaces

I have created a Setup Project in .Net studio 2005, an install class that is included in the setup project and launched as a custom action on install and commit phases.
This install class requires path of the installation for some of its functions - which i attempted to pass to it by adding following line

/MyAppPath=[TARGETDIR]

to the CustomActionData property of the custom action.
During installation if the path the user selects contains no spaces, install goes through fine. If it does install throws System.IO.FileNotFoundException (this is being thrown by installer, not my class because the error happens even with an empty Installer class)

Attempted install path: c:\Program Files\MyCompany\MyProgram
Error message:

Exception occured while initializing the installation:
System.IO.FileNotFoundException: Could not load file or assembly
file:///C:\WINDOWS\System32\Files\MyCompany\MyProgram\ or one of its dependancies. The system could not find file specified.

No error if path is given as c:\ProgramFiles\MyCompany\MyProgram

I have found my way arround the error by writing [TARGETDIR] to registry and then retrieving it from there in my install class. But it seems strange for windows installer to crash when it encounters file system path with spaces.

So I want to know if i did something wrong to stumble on this error, since from other posts i read about setup projects other people seem to be having no such problems with the TARGETDIR property
0
creepy42
Asked:
creepy42
1 Solution
 
alaranCommented:
Actually this is one of the more stupid and unnecessary problems i've come across in visual studio. I haven't found much documentation on why this is so, but it has to do with the way the installer invokes your custom action with arguments.
I've found that the following

Write /MyAppPath="[TARGETDIR]\" instead of /MyAppPath="[TARGETDIR]" (Note the enclosing "" and trailing \) in the CustomActionData property of the custom action. Play around with " and \ and you'll normally find a way.
0
 
creepy42Author Commented:
Thank you, the magic slash did the trick.
0

Featured Post

Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

Tackle projects and never again get stuck behind a technical roadblock.
Join Now