Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I fix 'Setup project with custom action file not found' exception?

I am trying to create a setup project for a Windows Service. I've followed the directions at http://support.microsoft.com/kb/816169 to create the setup project with no trouble.

I want to be able to get a value during the installation in order to update the app.config with the user's desired settings. I added a Textboxes (A) dialog to retrieve the values. I set the Edit1Property property to "TIMETORUN", and in my Primary Output action's CustomActionData property I put in the following: /TimeToRun="[TIMETORUN]\". So far so good. Running the setup I can retrieve the TimeToRun value from the Context.Parameters collection without issue.

In order to locate the app.config I need to also pass in the value of the TARGETDIR Windows Installer Property to my custom action. This is where things begin to fall apart. In order to achieve this, the above CustomActionData must be altered like so: /TimeToRun="[TIMETORUN]\" /TargetDir="[TARGETDIR]\". Now when I run the setup I get the following error message:

Error 1001. Exception occurred while initializing the installation. System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Windows\SysWOW64\Files' or one of its dependencies. The system cannot find the file specified.

If you google this problem you will inevitably find people having tremendous success by simply adding the trailing slash to the /TargetDir="[TARGETDIR]\" portion of the CustomActionData. This unfortunately does not solve my issue.

I tried so many different variations of the CustomActionData string and none of them worked. I tried logging to a file from my overridden Install method to determine where the breakage was, but no log file is created because it's not even getting that far. As the error indicates, the failure is during the Initialization step.

I have a hunch that it could be one of the dependencies that the setup project is trying to load. Perhaps somehow something is being appended to the CustomActionData string and isn't playing well with the TARGETDIR value (which contains spaces, i.e. "C:\Program Files\My Company\Project Name"). Again, this is another hunch that I cannot seem to confirm due to my inability to debug the setup process.

One further thing to mention, and yes it's another hunch, could this be an issue with Setup Projects on 64-bit version of Windows? I'm running Windows 7 Professional.

I'll provide names of the dependencies in case it helps:

  • Microsoft .NET Framework
  • Microsoft.SqlServer.DtsMsg.dll
  • Microsoft.SqlServer.DTSPipelineWrap.dll
  • Microsoft.SqlServer.DTSRuntimeWrap.dll
  • Microsoft.SQLServer.ManagedDTS.dll
  • Microsoft.SqlServer.msxml6_interop.dll
  • Microsoft.SqlServer.PipelineHost.dll
  • Microsoft.SqlServer.SqlTDiagM.dll

As you may glean from the dependencies, the Windows Service is scheduling a call to a DTSX package.

Sorry for the long rant. Thanks for any help you can provide.

like image 737
mikesigs Avatar asked Dec 23 '10 05:12

mikesigs


People also ask

How do I add custom actions in setup project?

In the Custom Actions Editor, select Install. On the Action menu, click Add Custom Action. In the Select Item in Project dialog box, double-click the Application Folder. Select the gadget assembly that was added to the setup project, and then click OK.

How do I create a custom action in Visual Studio?

To create the custom action, open the gadget project in Visual Studio. On the Project menu, select Add Class, select Installer Class in the Add New Item dialog box. Accept the default name of Installer1. cs, and then click Add.


1 Answers

The answer is so maddeningly simple. If the last argument in the CustomActionData is going to contain spaces and thus you have to surround it with quotes and a trailing slash, you must also have a space following the trailing slash, like this:

/TimeToRun="[TIMETORUN]\" /TargetDir="[TARGETDIR]\ " 

The solution and explanation can be found here.

like image 163
mikesigs Avatar answered Sep 18 '22 08:09

mikesigs