Freigeben über


MSI installation Fails while installing a Custom Action with “Error 1001. Exception occurred while initializing the installation”

 

Issue:

An MSI file built on Visual Studio fails during an installation with an error message

Error 1001. Exception occurred while initializing the installation:

System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\WINDOWS\system32\<file name>' or one of its dependencies. The system cannot find the file specified.

Cause:

This would happen when the syntax of a ‘CustomActionData property’ for a Custom Action is incorrectly defined in the MSI.

Example: /target=”[TARGETDIR]”; /source= “[SOURCEDIR]”

Resolution:

When you are installing a Custom Action as an installation component or the project installer classes the CustomActionData Property should be in the format of /name=value. If the value is a Windows installer property it should be passed as /name=[PROPERTYNAME] and if the property returns a directory the syntax should be /name=”[PROPERTYNAME]\” .

Follow the below steps to resolve the issue.

1. We have to find out in which Custom Action the syntax has been defined incorrectly and for this we should generate a log file of the MSI installation. Follow the article https://support.microsoft.com/kb/223300 to generate a MSI log file.

2. Search for text ‘value 3’ in the log file. This is the return value for a failed action in an MSI.

3. Copy the custom action name which returned value 3.

4. Edit the MSI file using a MSI editor like Orca and search for the “ %Custom Action%.SetProperty” in the Custom Action table. (%Custom Action% is the failed custom action name copied from the log file)

5. Choose the Target column in the row of “ %Custom Action%.SetProperty” and seeif there are any windows installer properties which return directories are given as values of a CustomActionData Property as mentioned above.

6. Make sure that all such values are following the syntax as /name=”[PROPERTYNAME]\” .

Example: /target=”[TARGETDIR]\” , /source=”[SOURCEDIR]\”.

After correcting the syntax CustomActionData Property the MSI shouldn’t throw the above error message anymore.

Content by : Sarat Chandra