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

  • 常见
  • DataAccess。
  • 用户界面
  • 组件
  • 测试

  • 我可以添加对Components.dll的引用。但是,当我运行解决方案时,出现了错误:


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

    你能帮我吗?

    这是构建输出:
    ------ 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 ==========
    

    最佳答案

    这是您的问题:

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

    假设您尝试运行.NET 4.0,则针对“轻量级”,“客户端配置文件”,“基类库”进行编译。您需要包含System.Web的成熟的Framework类库。

    解决方案

    为了更改此权限,请在AshyanehComps.dll的项目上单击鼠标右键,单击“属性”,再单击“应用程序”选项卡,然后将“目标框架”更改为“.NET Framework 4”。

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

    关于c# - 构建后缺少组装,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11263500/

    10-16 21:40