需要外部库的 WIX 安装程序自定义操作 (CA) 找不到它

发布于 2024-10-09 19:38:50 字数 1490 浏览 9 评论 0原文

我有一个调用两个 C# 自定义操作的 WIX 安装程序。

第一个运行例程,将具有默认值的 WIX 会话加载到 GUI 提示中以进行应用程序设置。然后,GUI 在安装过程中提示用户输入新值,这会将提供的设置存储到会话中。这运行得很好,然后在安装程序运行期间向用户显示提示。

然而,在 InstallFinalize 之后,应该运行另一个自定义操作来获取这些保存的设置,并将它们写入数据库和注册表。我编写了一个处理数据库连接的外部库,此自定义操作尝试加载并使用它,但失败并出现以下错误:

Exception thrown by custom action:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'myCompany.PortalLib, Version=2.9.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'myCompany.PortalLib, Version=2.9.0.0, Culture=neutral, PublicKeyToken=null'
   at WIXCustomActions.CustomActions.SetBCAConfigOptions(Session session)

详细信息:

  • 包含自定义操作函数的 VS 项目引用 myCompany.PortalLib。
  • csharp 自定义操作代码具有“using myCompany.PortalLib”指令。
  • 因该问题而卡住的 WIX 安装程序引用了 myCompany.PortalLib。
  • 我什至尝试将已编译的 myCompany.PortalLib.dll 文件的副本添加到 WIX 安装程序中,但无济于事。
  • makefxca 命令在由自定义操作项目生成时引用 (/r) myCompany.PortalLib.dll 文件以及 microsoft.deployment.windowsinstaller.dll 输出,并且当它运行时,它显示它包含在输出包中。

需要获取自定义操作以利用 myCompany.POrtalLib 才能写入服务器数据库...

  • 更新:我已尝试将 .dll 文件与自定义操作的 Packaged .dll 一起包含在 WIX 中,并在 XML 中引用它(在 HTML 尖括号中添加“[”):

    [Binary Id="myCompany.PortalLib.dll" SourceFile="myCompany.PortalLib.dll" /]

...并且我仍然收到上面的“无法加载文件或程序集”错误:(。

I have a WIX installer that calls two C# custom actions.

The first runs a routine to load the WIX session with default values into GUI prompts for application settings. The GUI then prompts the user during installation for new values, which stores the supplied settings to the session. This runs just fine and the user is then shown the prompts during the installer run.

After InstallFinalize, however, another custom action is supposed to run to take those saved settings, and write them to the database and registry. I have an external library I wrote that handles database connectivity, and this custom action attempts to load it and use it, failing with the following error:

Exception thrown by custom action:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'myCompany.PortalLib, Version=2.9.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'myCompany.PortalLib, Version=2.9.0.0, Culture=neutral, PublicKeyToken=null'
   at WIXCustomActions.CustomActions.SetBCAConfigOptions(Session session)

Details:

  • The VS project that contains the custom action functions references myCompany.PortalLib.
  • the csharp custom action code has "using myCompany.PortalLib" directive.
  • The WIX installer that chokes on this problem references myCompany.PortalLib.
  • I even tried adding a copy of the compiled myCompany.PortalLib.dll file into the WIX installer to no avail.
  • the makesfxca command references (/r) the myCompany.PortalLib.dll file along with the microsoft.deployment.windowsinstaller.dll output when built by the Custom Action project, and when it runs, it shows it is included in the output package.

Need to get the custom actions to utilize myCompany.POrtalLib to be able to write to the server database...

  • UPDATE: I've tried including the .dll file in the WIX alongside the Packaged .dll for the custom actions, and referencing it within the XML as such (subbing "[" for HTML angle brackets):

    [Binary Id="myCompany.PortalLib.dll" SourceFile="myCompany.PortalLib.dll" /]

...and I STILL get the "Could not load file or assembly" error above :(.

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

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

发布评论

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

评论(1

青柠芒果 2024-10-16 19:38:50

好吧,我也修好了这个!

我注意到,当我使用 makefxca 运行打包命令时,我正在打包自定义操作的 dll、Windows 安装程序的 dll 和 customaction.config。当我为 myCompany.PortalLib.dll 添加一个有效 dll 的路径以及这三个函数时,当需要执行该函数时,它工作得非常好...因此,将所有依赖的外部 dll 添加到打包的自定义操作 DLL 中与 makefxca 一起使用,以便包含外部 DLL 以与您的自定义操作一起使用。

Well I fixed this one too!

I noticed when I ran my packaging command using makesfxca, I was packaging the dll for the custom actions, the dll for windows installer, and the customaction.config. When I added a path to a valid dll for the myCompany.PortalLib.dll along with those three, when it came time to execute the function, it worked like a champ... So add all dependent external dlls into your packaged custom action DLL with makesfxca in order to have external DLLs included for use with your custom actions.

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