如何修复“找不到自定义操作文件的安装项目”例外?

发布于 2024-10-09 01:20:37 字数 1860 浏览 5 评论 0原文

我正在尝试为 Windows 服务创建一个安装项目。我已按照 http://support.microsoft.com/kb/816169 中的说明进行操作轻松创建安装项目。

我希望能够在安装过程中获取一个值,以便使用用户所需的设置更新 app.config。我添加了一个文本框(A)对话框来检索值。我将 Edit1Property 属性设置为“TIMETORUN”,并在主输出操作的 CustomActionData 属性中输入以下内容:/TimeToRun="[TIMETORUN]\" 。到目前为止,一切都很好。运行设置,我可以毫无问题地从 Context.Parameters 集合中检索 TimeToRun 值。

为了找到 app.config,我还需要将 TARGETDIR Windows Installer 属性的值传递给我的自定义操作。这就是事情开始崩溃的地方。为了实现这一点,上面的 CustomActionData 必须像这样进行更改:/TimeToRun="[TIMETORUN]\" /TargetDir="[TARGETDIR]\"。现在,当我运行安装程序时,我收到以下错误消息:

错误 1001。初始化安装时发生异常。 System.IO.FileNotFoundException:无法加载文件或程序集“file:///C:\Windows\SysWOW64\Files”或其依赖项之一。系统不能 查找指定的文件。

如果您用 google 搜索这个问题,您将不可避免地发现人们只需将尾部斜杠添加到 CustomActionData/TargetDir="[TARGETDIR]\" 部分即可取得巨大成功。不幸的是,这并不能解决我的问题。

我尝试了 CustomActionData 字符串的许多不同变体,但没有一个起作用。我尝试从覆盖的 Install 方法记录到文件以确定损坏的位置,但没有创建日志文件,因为它甚至没有达到那么远。正如错误所示,故障发生在初始化步骤期间。

我有预感,它可能是安装项目尝试加载的依赖项之一。也许不知何故,某些内容被附加到 CustomActionData 字符串中,并且与 TARGETDIR 值(包含空格,即“C:\Program Files\My Company\项目名称”)。同样,这是我似乎无法确认的另一个预感,因为我无法调试设置过程。

还要提一下,是的,这是另一种预感,这可能是 64 位版本 Windows 上的安装项目的问题吗?我运行的是 Windows 7 专业版。

我将提供依赖项的名称,以防有帮助:

  • 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

您可能会从依赖项中了解到,Windows 服务正在计划对 DTSX 包的调用。

抱歉长篇大论。感谢您提供的任何帮助。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

带上头具痛哭 2024-10-16 01:20:37

答案是如此简单得令人发狂。如果 CustomActionData 中的最后一个参数将包含空格,因此您必须用引号和尾部斜杠将其括起来,则尾部斜杠后面还必须有一个空格,如下所示

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

:可以在此处找到说明

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.

时光匆匆的小流年 2024-10-16 01:20:37

有类似的问题。就我而言,这很奇怪,因为我的安装程序已成功运行一次,然后我通过“添加/删除程序”成功卸载了我的应用程序,做了一些编码(没有触及我的CustomActionData字符串),并重建了我的项目和设置项目。当我重新运行 MSI 时,我收到了此错误。

我所做的编码是引入我在 CustomActionData 字符串中指定的更多参数的更多值。用于获取参数值的语法(即 string filepath = Context.Paramenters["filepath"]),位于我的 Installer 类中,实际上很好,但正如我发现的,我现在尝试从我的 CustomActionData 字符串中获取的后来的参数从一开始就不正确。我未能在其中一个参数周围添加第二个引号,因此无法获得其他任何内容。

我在用户界面部分使用“文本框(A)”和“文本框(B)”窗口。 A 有 1 个框,EDITA1,我在其中获取文件的路径,B 有 2 个框,EDITB1EDITB2,用于某些数据库参数。我的 CustomActionData 字符串如下所示:

/filepath="[EDITA1]" /host="[EDITB1] /port="[EDITB2]" 

它应该是:(

/filepath="[EDITA1]" /host="[EDITB1]" /port="[EDITB2]" 

[EDITB1] 上的结束引用)

Had a similar issue. In my case, it was odd because my installer had ran successfully once, then I uninstalled my app via Add/Remove Programs successfully, did some coding (did NOT touch my CustomActionData string), and rebuilt my project and setup project. It was when I re-ran my MSI that I got this error.

The coding I had done was to bring in more values of more parameters I had been specifying in my CustomActionData string. That syntax for getting the parameter values (i.e. string filepath = Context.Paramenters["filepath"]), which was in my Installer class, was actually fine, but as I found out, the syntax of the later parameters I was now trying to get from my CustomActionData string had not been correct, from the very beginning. I had failed to add a second quote around one of those parameters, so nothing else could be obtained.

I was using the "Textboxes (A)" and "Textboxes (B)" windows in the User Interface section. A has 1 box, EDITA1, where I get the path to a file, and B has 2 boxes, EDITB1 and EDITB2, for some database parameters. My CustomActionData string looked like this:

/filepath="[EDITA1]" /host="[EDITB1] /port="[EDITB2]" 

It should have been:

/filepath="[EDITA1]" /host="[EDITB1]" /port="[EDITB2]" 

(closing quote on [EDITB1])

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文