Visual Studio 2008 安装项目安装错误:“无法加载文件或程序集”
我遇到了一个显然很多人也遇到过的问题,只是对其他人有效的方法尚未对我有效。设置如下:
VS2008 解决方案有 5 个项目,全部针对 .NET 2.0:
- DLL A,没有项目引用
- DLL B,引用 DLL A
- Windows 窗体应用程序,引用 DLL B
- Windows 服务,引用 DLL B
- 设置项目
我想要什么 DLL A 和 DLL B 安装到 GAC 中,但我在安装时遇到错误:
错误 1001。无法加载文件或程序集“DLL_B”,版本 1.0.0.1,Culture=neutral,PublicKeyToken=5e297270603814f4”或其依赖项之一。系统找不到指定的文件。
根据我在此处和这里和一些在其他网站上,我以不特定的顺序执行了以下操作:
- 重新引用项目中的所有内容
- 将编译的 EXE 手动添加到安装项目中(而不是使用“主输出”... DLL A 和 DLL B 显示为“检测到”依赖项')
- 在安装项目中 ->启动条件 -> 在安装项目中将 .NET Framework 设置为 2.0
- ->文件系统->请求将检测到的依赖项安装到全局程序集缓存文件夹中,
因此,我可能遗漏了一些东西。谁能帮我弄清楚那是什么?
提前致谢。
I'm having an issue that apparently many people have had as well, only what has worked for others has not yet worked for me. Here is the setup:
VS2008 solution with 5 projects, all targeting .NET 2.0:
- DLL A, no project references
- DLL B, references DLL A
- Windows Forms App, references DLL B
- Windows Service, references DLL B
- Setup Project
What I want to happen is DLL A and DLL B get installed to the GAC, but I'm getting an error on installation:
Error 1001. Could not load file or assembly 'DLL_B', version 1.0.0.1, Culture=neutral, PublicKeyToken=5e297270603814f4' or one of its dependencies. The system could not find the file specified.
From what I read here and here and a few other sites, I have done the following in no particular order:
- Re-referenced everything in my projects
- Added the compiled EXEs manually to the setup project (instead of using 'Primary Output'... DLL A and DLL B came up as 'Detected Dependencies')
- In the setup project -> Launch Conditions -> set .NET Framework to 2.0
- In the setup project -> File System -> Requested that detected dependencies be installed to the Global Assembly Cache Folder
So, I'm probably missing something. Can anyone help me figure out what that is?
Thanks ahead of time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您正在使用 InstallUtil 自定义操作来安装和启动 Windows 服务,并且该 Windows 服务具有 GAC 中的依赖项。 Winodows Installer 的一个已知限制是,直到自定义操作触发后的提交阶段(延迟阶段)才会安装 WinSXS 和 GAC 文件。
首先,您应该知道 InstallUtil 自定义操作非常脆弱,并且有更好的方法方法来做到这一点。其次,您将永远无法解决我上面描述的问题,除非 a) 将服务设置为自动并重新启动,或者 b) 不将程序集安装到 GAC。
It sounds like you are using an InstallUtil custom action to install and start your windows service and that this windows service has a dependency that is in the GAC. It's a known limitation of Winodows Installer that files for the WinSXS and GAC aren't installed until the Commit phase which is after your Custom Action is firing ( Deferred Phase )
First you should know that InstallUtil custom actions are very fragile and that there are better ways to do this. Second you'll never be able to get around the problem I described above except to either a) Set the service to Auto and do a reboot or b) not install the assembly to the GAC.