gpt4 book ai didi

c# - 为什么我的 WiX 自定义操作会抛出 System.IO.FileNotFoundException?

转载 作者:行者123 更新时间:2023-12-02 15:29:14 26 4
gpt4 key购买 nike

我使用 Visual Studio 2010 以及 Windows 7、.net4 和最新 WiX 3.7 上的 Votive 插件来创建 msi。

安装相当复杂,在我的电脑上测试时效果很好。

在安装过程中,我运行了一些自定义操作。这些自定义操作之一需要外部 SQLite dll 来进行数据库访问,而该自定义操作仅需要该外部 SQLite dll。

当我在没有我的开发环境(只是普通的 Windows 7)的电脑上运行它时,我收到文件未找到错误。这看起来很明显是因为这台电脑上尚未安装 SQLite。

我得到的错误是:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SQLite.dll' or one of its dependencies. The specified module could not be found.

我可以从详细日志中看到自定义操作正在被提取到本地临时文件中以供运行。这是日志文件的摘录:

(SERVER)     MSI (s) (74:C0) [09:08:07:527]: Executing op: ActionStart(Name=InitializeDbDeferred,,)
(UNKNOWN) Action 09:08:07: InitializeDbDeferred.
(SERVER) MSI (s) (74:C0) [09:08:07:528]: Executing op: CustomActionSchedule(Action=InitializeDbDeferred,ActionType=1025,Source=BinaryData,Target=InsertDefaultRepositoryDeferred,CustomActionData=DATA=C:\AXS Standalone NVR;REPOSITORYPATH=C:\AXS Repository - (Available Space: 364 (Gb));QUOTA=25)
(SERVER) MSI (s) (74:88) [09:08:07:530]: Invoking remote custom action. DLL: C:\Windows\Installer\MSI4252.tmp, Entrypoint: InsertDefaultRepositoryDeferred
(UNKNOWN) SFXCA: Extracting custom action to temporary directory: C:\Users\Admin\AppData\Local\Temp\MSI4252.tmp-\
(UNKNOWN) SFXCA: Binding to CLR version v4.0.30319
(UNKNOWN) Calling custom action CustomAction!CustomAction.CustomAction.InsertDefaultRepositoryDeferred
(UNKNOWN) Exception thrown by custom action:
(UNKNOWN) System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SQLite.dll' or one of its dependencies. The specified module could not be found.
(UNKNOWN) at CustomAction.CustomAction.InsertDefaultRepositoryDeferred(Session session)
(UNKNOWN) --- End of inner exception stack trace ---

我的问题是,当 CA 从临时位置运行时,如何在安装过程中让自定义操作“查看”SQLite dll?我是否必须“以某种方式将 CA 和它的 dll 打包在一起?

我尝试将 SQLite dll 作为文件包含在安装程序中,但临时位置中的 CA 不会“知道”它在哪里。

我只是不知道如何让 CA 找到 SQLite dll。

最佳答案

Could not load file or assembly 'System.Data.SQLite.dll' or one of its dependencies

DTF 自动获取所有项目内容和程序集引用,并将它们压缩到最终的 native DLL 中。在自定义操作的生命周期内,您应该在临时目录中看到 SQLLite 程序集。

您会注意到错误消息显示“或其依赖项之一”。我会使用 ILDASM 或 .NET Reflector 查看 DLL,并查看该 DLL 的引用是什么。然后将它们作为项目(内容副本)或引用添加到您的 DTF 项目中。目标是将它们打包到最终的 DLL 中并将其放入临时目录。

关于c# - 为什么我的 WiX 自定义操作会抛出 System.IO.FileNotFoundException?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15246037/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com