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
creepy42Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
creepy42Author Commented:
Thank you, the magic slash did the trick.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.