构建后缺少组装

时间:2012-06-29 14:19:41

标签: c#

我的C#解决方案中有5个项目。

  1. 通用
  2. 数据访问。
  3. UI
  4. 部件
  5. 测试
  6. 我可以添加对Components.dll的引用。但是,当我运行解决方案时,我收到了错误:

      

    类型或命名空间名称“组件”不存在。

    Components.dll已存在于参考文件夹中。

    你能帮帮我吗?

    这是构建输出:

    ------ Rebuild All started: Project: Comps, Configuration: Release Any CPU ------
      Comps -> ..\Ashyaneh\Comps\bin\Release\AshyanehComps.dll
    ------ Rebuild All started: Project: Interfaces, Configuration: Debug Any CPU ------
      Interfaces -> ..\Ashyaneh\Interfaces\bin\Debug\AshyanehInterfaces.dll
    ------ Rebuild All started: Project: Common, Configuration: Debug Any CPU ------
      Common -> ..\Ashyaneh\Common\bin\Debug\AshyanehCommon.dll
    ------ Rebuild All started: Project: Web, Configuration: Debug Any CPU ------
      Web -> E:\My Programming 1391\HRShojaieWebAppRC2\Ashyaneh\Web\bin\Web.dll
    ------ Rebuild All started: Project: Test, Configuration: Debug x86 ------
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9):
    warning MSB3253: The referenced assembly "AshyanehComps.dll" could not be resolved
    because it has a dependency on "System.Web, Version=4.0.0.0, Culture=neutral,
    PublicKeyToken=b03f5f7f11d50a3a" which is not in the currently targeted framework
    ".NETFramework,Version=v4.0,Profile=Client". Please remove references to assemblies
    not in the targeted framework or consider retargeting your project.
      Test -> ..\Ashyaneh\Test\bin\Debug\Test.exe
    ========== Rebuild All: 5 succeeded, 0 failed, 0 skipped ==========
    

7 个答案:

答案 0 :(得分:16)

这是你的问题:

引用的程序集“E:\ My Programming 1391 \ HRShojaieWebAppRC2 \ Ashyaneh \ Comps \ bin \ Release \ AshyanehComps.dll”无法解析,因为它依赖于“System.Web,Version = 4.0。 0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a“不在当前目标框架中”.NETFramework,Version = v4.0,Profile = Client“

假设您正在尝试运行.NET 4.0,那么您正在针对“轻量级”客户端配置文件基类库进行编译。您需要包含System.Web的完整框架类库。

<强>解决方案

要更改此权限,请右键单击Project for AshyanehComps.dll&gt;点击属性&gt;点击“申请”标签&gt;将“目标框架”更改为“.NET Framework 4”。

为了安全起见,我会按照上述步骤对您解决方案中的所有项目进行操作,您应该做得很好。

答案 1 :(得分:1)

您是否确定通过右键单击出现错误的项目并单击“添加引用”并选择项目引用,在每个需要的位置添加组件作为参考?

如果完成上述操作,我将遵循以下流程:

  • 全部保存
  • 关闭Visual Studio
  • 删除每个项目中的BIN和OBJ文件夹
  • 重启VS
  • 再试一次

如果它仍然不起作用,那么您可能需要调整构建顺序。右键单击解决方案并确保每个项目都以正确的依赖顺序构建,并确保您没有任何循环依赖项。

答案 2 :(得分:0)

验证您在提交解决方案时保存csproj,因为您的csproj包含您的引用:

  

答案 3 :(得分:0)

验证您的主应用程序目标框架未设置为.Net Framework 4.0 Client Profile。 如果设置为this,请更改它并将其设置为.Net framework 4.0。

您可以看到如何更改 http://msdn.microsoft.com/en-us/library/bb398202.aspx

答案 4 :(得分:0)

首先,您有5个项目。 您必须确定哪个'组件'报告在哪个特定项目中不存在?

然后你去项目引用添加(重新添加,如果它在那里让VS refrence缓存生成)到项目。检查是否需要“复制到本地”选项或验证全局装配路径。

现在你完成所有参考,如果问题仍然存在, 检查您的项目代码(特定行),看看它为什么不起作用。发布MS Build输出,它会告诉。

答案 5 :(得分:0)

  • 当您将“组件”项目添加到其他项目作为参考时, 在“添加引用”屏幕中,不在“项目”选项卡中添加引用 浏览“组件”项目输出路径(Components.dll)中的选项卡。

  • 然后,清除您的解决方案并构建您的“组件”项目。

  • 如果您的“组件”项目中有错误,请解决它们。

  • 最后构建您的解决方案。

答案 6 :(得分:0)

最有可能你是应用程序目标框架是像我的4.0客户端配置文件。除非您使用特定于4.0的内容,否则解决方案是将其降低到3.5并且错误消失。谢谢微软。