Saturday, March 29, 2008

Custom Actions With .Net Installer Class Yields Weird Error

The Error

The other day I was writing a custom installer for some SharePoint stuff. I ended up customizing the UI a little and mapping those user inputs to properties that I would refer to some custom actions class that I wrote.

I was following a tutorial on the web and everything seemed to be going fine until I added all my properties, ran the installer and then bam!

Low to my surprise, when I ran the installer I ended up getting an error of the form:

Error 1001. Exception occurred while initializing the installation: System.IO.FileNotFound: Could not load file or assembly 'file:///[path]' or one of it's dependencies. The system cannot find the file specified.

I ended up digging around on the web for a bit and couldn't really find anything, so after I fixed it I decided that this gotcha might deserve to be immortalized in a blog entry.

The Solution (at least for me)

The fix was of course something silly. I'm almost embarrassed. When you pass custom properties that are file paths that include spaces in them (ie. 'C:\Program Files\...') you need to wrap the whole path in quotes, this goes for custom properties too.

Further more if you're passing in the path of the installation directory (TARGETDIR) you need to not only wrap it in quotes but also put a back slash on the end of it.

/name="[TARGETDIR]\"

There's more information on the MSDN.

So I fixed my custom action expressions by wrapping them in quotes (and putting a trailing backslash on [TARGETDIR] AND I'm good to go! No more angry error.Putting quotes (

Maybe next time I'll RTFM.

Best,
Tyler

2 comments:

Anonymous said...

Old post but still very useaful, thanx! :)

electronic signature pad said...

I really liked this post. You explain this topic very well. I really like your blog and I will definitely bookmark it! Keep up the super posts!