添加项目作为参考结果无法加载文件或程序集或其中一个依赖项

时间:2013-10-07 14:39:29

标签: c# visual-studio-2012 dll wix fusion

我在Visual Studio 2012中有一个包含多个项目的解决方案。我正在尝试将项目添加到另一个项目作为参考,以便能够一起使用它们,但我无法弄清楚为什么添加此项目引用导致在部署/运行时丢失DLL(FusionLog下面)。我之前没有使用过这种方法,所以我必须在这里遗漏一些东西......

解决方案配置:

主要项目:Bootstrapper
子项目:BootstrapperCustom
项目我尝试添加为参考:LicenseCheckBootstrapperCustom
部署时缺少DLL:LicenseCheck.dll

[Bootstrapper]
--Installer: Configuration: N/A, Platform: N/A
--Build: Configuration: Active (Debug), Platform: Active (x86)
--Ref:
----[BootstrapperCustom]

[BootstrapperCustom]
--Application: Configuration: N/A, Platform: N/A, Target framework: .NET 4.5, Output type: Class library
--Build: Configuration: Active (Debug), Platform: Active (Any CPU), Platform target: Any CPU
--Ref:
----[BootstrapperCore] (Copy Local: True)
----[LicenseCheck] (Copy Local: True)
----[Microsoft.Deployment.WindowsInstaller] (Copy Local: True)
----[Microsoft.Practices.Prism] (Copy Local: True)

[LicenseCheck]
--Application: Configuration: N/A, Platform: N/A, Target framework: .NET 4.5, Output type: Class library
--Build: Configuration: Active (Debug), Platform: Active (x86), Platform target: Any CPU
--Ref:
----[Microsoft.Deployment.WindowsInstaller] (Copy Local: True)
----[Parse] (Copy Local: True)

错误讯息:

Run Bootstrapper.exe = `Could not load file or assembly 'LicenseCheck, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.`

FusionLog(已确认LicenseCheck.dll丢失):

[%TEMP%\{x}\.ba1]
--BootstrapperCore.dll
--BootstrapperCustom.dll
--Microsoft.Practices.Prism.dll

=== Pre-bind state information ===
LOG: User = NOTTHOR\dirt
LOG: DisplayName = LicenseCheck, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = file:///C:/Users/dirt/AppData/Local/Temp/{94ef2c32-a419-410e-a8a0-df404f022ff7}/.ba1/
LOG: Initial PrivatePath = NULL
Calling assembly : BootstrapperCustom, Version=1.0.5028.16514, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\dirt\AppData\Local\Temp\{94ef2c32-a419-410e-a8a0-df404f022ff7}\.ba1\BootstrapperCore.config
LOG: Using host configuration file: C:\Users\dirt\AppData\Local\Temp\{94ef2c32-a419-410e-a8a0-df404f022ff7}\.ba1\BootstrapperCore.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Users/dirt/AppData/Local/Temp/{94ef2c32-a419-410e-a8a0-df404f022ff7}/.ba1/LicenseCheck.DLL.
LOG: Attempting download of new URL file:///C:/Users/dirt/AppData/Local/Temp/{94ef2c32-a419-410e-a8a0-df404f022ff7}/.ba1/LicenseCheck/LicenseCheck.DLL.
LOG: Attempting download of new URL file:///C:/Users/dirt/AppData/Local/Temp/{94ef2c32-a419-410e-a8a0-df404f022ff7}/.ba1/LicenseCheck.EXE.
LOG: Attempting download of new URL file:///C:/Users/dirt/AppData/Local/Temp/{94ef2c32-a419-410e-a8a0-df404f022ff7}/.ba1/LicenseCheck/LicenseCheck.EXE.

注意:当我重建BootstrapperCustom项目时,我执行请参阅Bootstrapper\bin\Debug中生成的LicenseCheck.dll。

4 个答案:

答案 0 :(得分:1)

您是否尝试查看您引用的项目是否使用 LicenseCheck dll文件,但实际上引用它? (例如:您引用的项目可能在初始化期间动态加载dll。)

如果是这种情况,您可以添加构建步骤以将dll复制到输出文件夹(例如,请参阅Copying files into the application folder at compile time

答案 1 :(得分:0)

原来这是主项目(WiX Bootstrapper)配置中的内容。我没有将LicenseCheck.dll包含在BootstrapperApplication的Payload列表中。

添加到Bootstrapper \ Bundle.wxs:

<Payload SourceFile="$(var.BootstrapperCustom.TargetDir)LicenseCheck.dll" />

答案 2 :(得分:0)

在解决方案资源管理器中,右键单击并重建该项目。 查看是否在Windows资源管理器中重新生成了dll。 要使其正常工作,只需将该项目中的dll复制到主项目bin文件夹即可。它应该工作。 这是一个最糟糕的情况,只需启动并运行

答案 3 :(得分:0)

我知道这不是你的答案,但我带着相同的错误信息来到这里,寻找寻找灵感的灵感。事实证明,我引用的项目是一个比我的主项目更新的目标框架。